@napp/exception
Version:
common exception. node application common library. serialization error
45 lines (44 loc) • 1.38 kB
TypeScript
import { IException } from "./common";
export type IExceptionData = Record<string, any>;
export interface ExceptionOption {
name: string;
code?: string;
data?: IExceptionData;
cause?: IException;
source?: any;
stack?: string;
}
export interface IExceptionParser {
parse(err: any): Exception | false;
}
export declare class ExceptionParser implements IExceptionParser {
private resolve;
parse(err: any): false | Exception;
}
export declare class Exception extends Error implements IException {
static Authorization: string;
static Authentication: string;
static Notfound: string;
static Validation: string;
static Unsupported: string;
static Unavailable: string;
static InternalServer: string;
static Timeout: string;
code?: string;
cause?: IException;
stack?: string;
data?: IExceptionData;
source?: any;
constructor(msg: string | [code: string, message: string], opt?: ExceptionOption);
setName(name: string): this;
setCode(code: string): this;
setMessage(msg: string): this;
setData(data: IExceptionData): this;
setCause(err: any): this;
setSource(source: any): this;
setStack(stack: string): this;
toPlan(): IException;
toJSON(): IException;
static parser: IExceptionParser;
static from(err: any, parser?: IExceptionParser): Exception;
}