import { DeserializeOpts, HighLevelErrorInternal, HLDefs, IBaseError, IErrorRegistryConfig, IErrorRegistryContextConfig, KeyOfStr, LLDefs, LowLevelErrorInternal, SerializedError } from './interfaces'; import { BaseRegistryError } from './error-types/BaseRegistryError'; /** * Contains the definitions for High and Low Level Errors and * generates custom errors from those definitions. */ export declare class ErrorRegistry>, LLErrors extends LLDefs>> { /** * High level error definitions */ protected highLevelErrors: HLErrors; /** * A map of high level names to class name */ protected classNameHighLevelNameMap: Record, string>; /** * Cached high level error classes */ protected highLevelErrorClasses: Record, typeof BaseRegistryError>; /** * Low level error definitions */ protected lowLevelErrors: LLErrors; /** * Error registry configuration */ protected _config: IErrorRegistryConfig; /** * Error metadata to always include in an error */ protected _newErrorContext: IErrorRegistryContextConfig | null; constructor(highLvErrors: HLErrors, lowLvErrors: LLErrors, config?: IErrorRegistryConfig); /** * Gets the definition of a High Level Error * @param {string} highLvErrName */ protected getHighLevelError(highLvErrName: KeyOfStr): HighLevelErrorInternal; /** * Gets the definition of a Low Level Error * @param {string} lowLvErrName */ protected getLowLevelError(lowLvErrName: KeyOfStr): LowLevelErrorInternal; /** * Gets the class definition of a High Level Error * @param highLvErrName */ getClass(highLvErrName: KeyOfStr): typeof BaseRegistryError; /** * Compares an instance of an object to a specified High Level Error */ instanceOf(a: any, highLvErrName: KeyOfStr): boolean; /** * Creates an instance of a High Level Error, without a Low Level Error * attached to it. * @param {string} highLvErrName * @param {string} [message] Error message. If not defined and the high level error has the * message property defined, will use that instead. If the high level error message is not defined, * then will use the high level error id instead for the message. */ newBareError(highLvErrName: KeyOfStr, message?: string): BaseRegistryError; /** * Creates an instance of a High Level Error, with a Low Level Error * attached to it. * @param {string} highLvErrName * @param {string} lowLvErrName */ newError(highLvErrName: KeyOfStr, lowLvErrName: KeyOfStr): BaseRegistryError; /** * Updates the stack trace to remove the error registry entry: * "at ErrorRegistry.newError" and related entries */ private reformatTrace; /** * If a new error context is defined, then set the values */ private assignErrContext; /** * Deserializes data into an error * @param {string} data JSON.parse()'d error object from * BaseError#toJSON() or BaseError#toJSONSafe() * @param {DeserializeOpts} [opts] Deserialization options */ fromJSON(data: Partial, opts?: U): T; /** * Creates a new error registry instance that will include / set specific data * for each new error created. * * Memory overhead should be trivial as the internal *references* of the existing * error registry instance properties is copied over to the new instance. */ withContext(context: IErrorRegistryContextConfig): ErrorRegistry; }