mirror of
https://github.com/langgenius/dify.git
synced 2026-01-30 07:32:45 +08:00
Some checks are pending
autofix.ci / autofix (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
Main CI Pipeline / Check Changed Files (push) Waiting to run
Main CI Pipeline / API Tests (push) Blocked by required conditions
Main CI Pipeline / Web Tests (push) Blocked by required conditions
Main CI Pipeline / Style Check (push) Waiting to run
Main CI Pipeline / VDB Tests (push) Blocked by required conditions
Main CI Pipeline / DB Migration Test (push) Blocked by required conditions
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
76 lines
1.9 KiB
TypeScript
76 lines
1.9 KiB
TypeScript
export type DifyErrorOptions = {
|
|
statusCode?: number;
|
|
responseBody?: unknown;
|
|
requestId?: string;
|
|
retryAfter?: number;
|
|
cause?: unknown;
|
|
};
|
|
|
|
export class DifyError extends Error {
|
|
statusCode?: number;
|
|
responseBody?: unknown;
|
|
requestId?: string;
|
|
retryAfter?: number;
|
|
|
|
constructor(message: string, options: DifyErrorOptions = {}) {
|
|
super(message);
|
|
this.name = "DifyError";
|
|
this.statusCode = options.statusCode;
|
|
this.responseBody = options.responseBody;
|
|
this.requestId = options.requestId;
|
|
this.retryAfter = options.retryAfter;
|
|
if (options.cause) {
|
|
(this as { cause?: unknown }).cause = options.cause;
|
|
}
|
|
}
|
|
}
|
|
|
|
export class APIError extends DifyError {
|
|
constructor(message: string, options: DifyErrorOptions = {}) {
|
|
super(message, options);
|
|
this.name = "APIError";
|
|
}
|
|
}
|
|
|
|
export class AuthenticationError extends APIError {
|
|
constructor(message: string, options: DifyErrorOptions = {}) {
|
|
super(message, options);
|
|
this.name = "AuthenticationError";
|
|
}
|
|
}
|
|
|
|
export class RateLimitError extends APIError {
|
|
constructor(message: string, options: DifyErrorOptions = {}) {
|
|
super(message, options);
|
|
this.name = "RateLimitError";
|
|
}
|
|
}
|
|
|
|
export class ValidationError extends APIError {
|
|
constructor(message: string, options: DifyErrorOptions = {}) {
|
|
super(message, options);
|
|
this.name = "ValidationError";
|
|
}
|
|
}
|
|
|
|
export class NetworkError extends DifyError {
|
|
constructor(message: string, options: DifyErrorOptions = {}) {
|
|
super(message, options);
|
|
this.name = "NetworkError";
|
|
}
|
|
}
|
|
|
|
export class TimeoutError extends DifyError {
|
|
constructor(message: string, options: DifyErrorOptions = {}) {
|
|
super(message, options);
|
|
this.name = "TimeoutError";
|
|
}
|
|
}
|
|
|
|
export class FileUploadError extends DifyError {
|
|
constructor(message: string, options: DifyErrorOptions = {}) {
|
|
super(message, options);
|
|
this.name = "FileUploadError";
|
|
}
|
|
}
|