ts-api-core
Version:
Nodejs api framework core
30 lines (29 loc) • 976 B
TypeScript
import { Result, ResultCode } from '../../base/result';
export declare class BaseError extends Error {
get code(): number;
set code(value: number);
private _code;
private readonly data;
static _FAILURE_MSG: string;
constructor(code?: ResultCode, msg?: string, data?: any, errorName?: string);
getResponseObject<T>(): Result<T>;
/**
* 抛出一个默认的错误,允许自定义消息
* @param msg 消息
* @param data 返回的data
*/
static throwDefaultError(msg?: string, data?: any | undefined): BaseError;
/**
* 包装错误对象并向外抛出
* @param error 错误对象
* @param action 正在执行的动作
* @param data 返回的data
*/
static throwError(error: Error | undefined, action?: string, data?: any): void;
}
/**
* 参数错误
*/
export declare class ParamError extends BaseError {
constructor(data: string);
}