error.d.ts 2.4 KB

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