UNPKG

macoolka-error

Version:

`macoolka-cache` Build a cache for function

48 lines (46 loc) 1.24 kB
/** * create A error string. * @desczh * 创建一个错误文本 * @example import { CreateErrorString} from 'macoolka-functions' const errorString = CreateErrorString('Macoolka Functions') const e = new TypeError('unit test'); expect(errorString('error message', e)).toContain( '[Macoolka Functions] error message\nTypeError: unit test' ); expect(errorString('error message')).toContain( '[Macoolka Functions] error message' ); * @since 0.2.2 * */ export declare const wrapErrorToString: ({ title, message, exception }: { title?: string | undefined; message: string; exception?: Error | undefined; }) => string; /** * Error to string.(short) * * Only with name and message * @desczh * 错误信息转换成文本。(短格式,仅显示name和message) * @since 0.2.2 */ export declare const errorToShortString: (exception: Error) => string; /** * Error to string.(short) * @desczh * 错误信息转换成文本。 * @since 0.2.2 */ export declare const errorToString: (exception: Error) => string; /** * default error handler * * write error info to console When process.env.NODE_ENV !== 'production' * * @since 0.2.2 */ export declare function defaultErrorHandler(error: string | Error): void;