error.d.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { Headers } from "./core.js";
  2. export declare class OpenAIError extends Error {
  3. }
  4. export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends OpenAIError {
  5. /** HTTP status for the response that caused the error */
  6. readonly status: TStatus;
  7. /** HTTP headers for the response that caused the error */
  8. readonly headers: THeaders;
  9. /** JSON body of the response that caused the error */
  10. readonly error: TError;
  11. readonly code: string | null | undefined;
  12. readonly param: string | null | undefined;
  13. readonly type: string | undefined;
  14. readonly request_id: string | null | undefined;
  15. constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders);
  16. private static makeMessage;
  17. static generate(status: number | undefined, errorResponse: Object | undefined, message: string | undefined, headers: Headers | undefined): APIError;
  18. }
  19. export declare class APIUserAbortError extends APIError<undefined, undefined, undefined> {
  20. constructor({ message }?: {
  21. message?: string;
  22. });
  23. }
  24. export declare class APIConnectionError extends APIError<undefined, undefined, undefined> {
  25. constructor({ message, cause }: {
  26. message?: string | undefined;
  27. cause?: Error | undefined;
  28. });
  29. }
  30. export declare class APIConnectionTimeoutError extends APIConnectionError {
  31. constructor({ message }?: {
  32. message?: string;
  33. });
  34. }
  35. export declare class BadRequestError extends APIError<400, Headers> {
  36. }
  37. export declare class AuthenticationError extends APIError<401, Headers> {
  38. }
  39. export declare class PermissionDeniedError extends APIError<403, Headers> {
  40. }
  41. export declare class NotFoundError extends APIError<404, Headers> {
  42. }
  43. export declare class ConflictError extends APIError<409, Headers> {
  44. }
  45. export declare class UnprocessableEntityError extends APIError<422, Headers> {
  46. }
  47. export declare class RateLimitError extends APIError<429, Headers> {
  48. }
  49. export declare class InternalServerError extends APIError<number, Headers> {
  50. }
  51. export declare class LengthFinishReasonError extends OpenAIError {
  52. constructor();
  53. }
  54. export declare class ContentFilterFinishReasonError extends OpenAIError {
  55. constructor();
  56. }
  57. //# sourceMappingURL=error.d.ts.map