UNPKG

error-message-utils

Version:

The error-message-utils package simplifies error management in your web applications and RESTful APIs. It ensures consistent and scalable handling of error messages, saving you time and effort. Moreover, it gives you the ability to assign custom error cod

19 lines (18 loc) 741 B
import { IErrorCodeWrapper, IErrorCode, IUnwrappedErrorCode } from '../shared/types.js'; declare const CODE_WRAPPER: IErrorCodeWrapper; declare const DEFAULT_MESSAGE: string; declare const DEFAULT_CODE: IErrorCode; /** * Wraps a given error code. If none is provided, it wraps the default code. * @param code * @returns string */ declare const wrapCode: (code: IErrorCode) => string; /** * Verifies if a message is an encoded error and if so, attempts to extract the code. * If unsuccessful, both code and startsAt values will be -1. * @param message * @returns IUnwrappedErrorCode */ declare const unwrapCode: (message: string) => IUnwrappedErrorCode; export { CODE_WRAPPER, DEFAULT_MESSAGE, DEFAULT_CODE, wrapCode, unwrapCode, };