Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.9 KB
Raw Blame
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'
  }
}