UNPKG

@rimbu/common

Version:

Common types and objects used in many other Rimbu packages

34 lines (33 loc) 994 B
/** * Throws an `Err.ForcedError` error when called. * @example * ```ts * const emptyMap = HashMap.empty<number, string>() * emptyMap.get(5, Err); * // throws: Err.CustomError(message: 'Err: forced to throw error') * ``` */ export declare function Err(): never; export declare namespace ErrBase { /** * A custom error instance. */ abstract class CustomError { readonly message: string; constructor(message: string); get name(): string; } class ForcedError extends CustomError { } /** * Returns a function that, when called, throws an `Err.ForcedError` with the given `message` string. * @param message - the message to put in the `Err.ForcedError` instance. * @example * ```ts * const emptyMap = HashMap.empty<number, string>() * emptyMap.get(5, ErrBase.msg('not found')); * // throws: Err.CustomError(message: 'not found') * ``` */ function msg(message: string): () => never; }