UNPKG

@calljmp/cli

Version:
54 lines 1.58 kB
/** * Error codes returned by the service. */ export declare enum ServiceErrorCode { Internal = 1000, NotFound = 1001, Unauthorized = 1002, BadRequest = 1003, Forbidden = 1004, TooManyRequests = 1005, UserAlreadyExists = 2000, UserNotFound = 2001, ProjectAlreadyExists = 2100, UsageExceeded = 3000, ResourceBusy = 3001 } /** * Represents an error returned by the service, including a code and message. */ export declare class ServiceError extends Error { code: ServiceErrorCode; /** * Creates a new ServiceError instance. * @param message Error message * @param code Service error code */ constructor(message: string, code: ServiceErrorCode); /** * Creates a ServiceError from a ServiceErrorCode. * @param code Service error code * @returns ServiceError instance */ static fromCode(code: ServiceErrorCode): ServiceError; /** * Creates a ServiceError from a JSON object. * @param json JSON object with message and code * @returns ServiceError instance */ static fromJson(json: Record<string, any>): ServiceError; /** * Gets the HTTP status code corresponding to the service error code. * @returns HTTP status code */ get statusCode(): 404 | 401 | 400 | 403 | 429 | 409 | 402 | 503 | 500; /** * Serializes the ServiceError to a JSON object. * @returns JSON representation of the error */ toJson(): { message: string; code: ServiceErrorCode; }; } //# sourceMappingURL=error.d.ts.map