/** * Accepted constructor inputs for exceptions */ export type ExceptionInput = StandardException | Error | string | null | undefined; /** * Exception interface * Support usages: * throw new Exception(); * throw new Exception('Something'); * throw new Exception(new Error()); * throw new Exception(new Exception()); * throw (new Exception()).i18n('some %d', 123) */ export declare class StandardException extends Error { /** * Generate string hash by crc32 */ static hash(str: string, padstr?: string): string; /** * Hash an exception into an 18 bits code */ static generateCode(className: string, fileName?: string): number; /** * Remove useless info from error stack */ static stackBeautifier(stack: string): string[]; static setI18nHandler(handler: (...args: unknown[]) => string): void; /** * Deserialize an exception from a JSON object */ static factory(json?: Record): Record | StandardException | undefined; /** * Http status code */ get statusCode(): number; humanMessage: string; throwingError: boolean; details: unknown; prevError: unknown; code: number | null; filename: string; translated: boolean; importance: number; /** * If throw a StandardException, keep throw to above * If throw a Error, set Error message to exception message, set Error to details * If throw a String, set String to exception message * If throw a null or undefined, set exception name as exception message * Otherwise, throw a TypeError */ constructor(exceptionOrMsg?: ExceptionInput); i18n(...args: unknown[]): this; getHumanMessage(): string; setMessage(message: string): this; setCode(code: number | string): this; getCode(): number; getStatusCode(): number; setImportance(importance: number | string): this; getImportance(): number; setFileName(filename: string): this; getFileName(): string; setDetails(details: unknown): this; getDetails(): unknown[]; setPrevError(prevError: unknown): this; getPrevError(): unknown; toJSON(): { statusCode: number; code: number; name: string; message: string; humanMessage: string; filename: string; prevError: unknown; errors: unknown[]; stack: string[]; fullStack: string[]; }; } export declare class LogicException extends StandardException { get statusCode(): number; } export declare class InvalidArgumentException extends LogicException { } export declare class FormInvalidateException extends InvalidArgumentException { constructor(exceptionOrMsg?: ExceptionInput); } export declare class ModelInvalidateException extends InvalidArgumentException { constructor(exceptionOrMsg?: ExceptionInput); } export declare class HttpRequestLogicException extends InvalidArgumentException { response: unknown; request: unknown; requestParams: unknown; responseParams: unknown; businessCode: unknown; /** * Support request promise error * https://github.com/request/promise-core/blob/master/lib/errors.js */ constructor(exceptionOrMsg?: ExceptionInput); setResponse(response: unknown): this; getRequest(): {}; getResponse(): {}; setRequestParams(params: unknown): this; getRequestParams(): unknown; setResponseParams(params: unknown): this; getResponseParams(): unknown; setBusinessCode(code: unknown): this; getBusinessCode(): unknown; } export declare class RestServiceLogicException extends HttpRequestLogicException { constructor(exceptionOrMsg?: ExceptionInput); } export declare class UnauthorizedException extends LogicException { get statusCode(): number; } export declare class OperationNotPermittedException extends LogicException { get statusCode(): number; } export declare class ResourceNotFoundException extends LogicException { get statusCode(): number; } export declare class OperationUnsupportedException extends LogicException { get statusCode(): number; } export declare class ResourceConflictedException extends LogicException { get statusCode(): number; } export declare class RuntimeException extends StandardException { } export declare class IOException extends RuntimeException { } export declare class HttpRequestIOException extends IOException { response: unknown; request: unknown; requestParams: unknown; responseParams: unknown; businessCode: unknown; constructor(exceptionOrMsg?: ExceptionInput); getRequest(): unknown; getResponse(): unknown; setRequestParams(params: unknown): this; getRequestParams(): unknown; setResponseParams(params: unknown): this; getResponseParams(): unknown; setBusinessCode(code: unknown): this; getBusinessCode(): unknown; } export declare class RestServiceIOException extends HttpRequestIOException { constructor(exceptionOrMsg?: ExceptionInput); } export declare class DatabaseIOException extends IOException { }