UNPKG

@lifi/rpc-wrapper

Version:
35 lines (34 loc) 1.47 kB
import { Static } from '@sinclair/typebox'; export declare type Values<E> = E[keyof E]; /** * Converts an error into a json object * * @param error - Error to convert * @returns An error json */ export declare const jsonifyError: (error: CustomError | Error) => CustomErrorJson; export declare const CustomErrorJsonSchema: import("@sinclair/typebox").TObject<{ message: import("@sinclair/typebox").TString<string>; context: import("@sinclair/typebox").TAny; type: import("@sinclair/typebox").TString<string>; stack: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>; }>; export declare type CustomErrorJson = Static<typeof CustomErrorJsonSchema>; /** * @classdesc The error class used throughout this repo. Defines a context object in addition to the standard message and name fields. The context can hold any information in json form that is relevant to the error * * Is also able to be hydrated from a json */ export declare class CustomError extends Error { readonly msg: Values<typeof CustomError.reasons>; readonly context: any; readonly type: string; readonly level: 'warn' | 'error'; readonly isCustomError = true; static readonly reasons: { [key: string]: string; }; constructor(msg: Values<typeof CustomError.reasons>, context?: any, type?: string, level?: 'warn' | 'error'); toJson(): CustomErrorJson; static fromJson(json: CustomErrorJson): CustomError; }