@angstone/monostone
Version:
monolitic event-sourced framework
45 lines (44 loc) • 1.64 kB
TypeScript
export declare const MONOSTONE_ERROR: string;
export declare const OPERATIONAL_PREFIX: string;
export declare const FATAL_PREFIX: string;
/**
* Centralized unique error type
*/
export declare class MonoError extends Error {
readonly type: string;
readonly details: any[] | any;
/**
* @param message string optional
* @param details any details
*/
constructor(message?: string, ...details: any[] | any);
}
/**
* shortcuts functions to make easy dealing with errors
*/
export declare const error: {
/**
* creates the error (same as new Error(...))
* @param message string optional
* @param details any details
*/
is(message?: string | undefined, ...details: any): MonoError;
/**
* print error to console
* @param message the text message of the error OR the generated error itself (Error or MonoError)
* @param ...details any number of objects to include with the error
*/
op(message?: string | Error | undefined, ...details: any[]): void;
/**
* print a fatal error to console and terminates the application
* @param message the text message of the error OR the generated error itself (Error or MonoError)
* @param ...details any number of objects to include with the error
*/
fatal(message?: string | Error | undefined, ...details: any[]): void;
/**
* throw a new error with the message
* @param message can be a string or an instance of Error
* @param ...details any number of objects to include with the error
*/
throw(message?: string | Error | undefined, ...details: any): never;
};