/** 调接口出错。 */
export class ApiError extends Error {
  status = 500
  // 机器可读的错误码
  static readonly kind: string = 'API_ERROR'

  constructor(message: string, public code?: string) {
    super(message)
  }

  toJSON() {
    return { status: this.status, code: this.code }
  }
}

export class NotFoundError extends ApiError {
  status = 404 // 找不到
}

class Slow extends Timeout {}

class Timeout extends NotFoundError {}

const Cancelled = class extends RangeError {}

export class Forbidden extends errors.HttpException<string> {}

export class Repository extends Base {
  status = 1
}
