import { AxiosResponse } from 'axios'; import { AlBaseError, AlWrappedError, AlCabinet } from '../common'; export interface AlErrorDescriptor { title: string; description: string; details?: any; } /** * AlErrorHandler is a utility class meant to simplify error logging, upstream error reporting, and general error * formatting. */ export declare class AlErrorHandler { static initialized: boolean; static categories: { [cat: string]: boolean; }; static upstream?: { (error: AlBaseError): void; }; static verbose: boolean; protected static storage: AlCabinet; /** * Logs a normalized error message to the console. * * @param error Can be an AxiosResponse, Error, string, or anything else (although "anything else" will be handled with a generic error message); * @param commentary If provided, is used to describe the error; * @param categoryId If provided, describes the category of the logging output. * @param overrideVerbosity If provided, the error will always be emitted to the console */ static log(error: AxiosResponse | AlBaseError | Error | string | any, commentary?: string, categoryId?: string, overrideVerbosity?: boolean): void; /** * Reports an error to an external error reporting service (which must be attached separately) * * @param error A network error response, `Error` instance of any type, or string. * @param commentary If provided, it is used to describe the error in its console output and internally (not user facing). */ static report(error: AxiosResponse | AlBaseError | Error | string | any, commentary?: string): void; /** * Normalizes an error into an AlBaseError. * * @param error Can be an AxiosResponse (in which case the method will return an AlAPIServerError), * any other Error or derived class, string, or anything. * @returns AlBaseError of the appropriate flavor. */ static normalize(error: AxiosResponse | AlBaseError | Error | string | any, commentary?: string): AlBaseError; /** * Enables logging of one or more error categories. The default category is "general". */ static enable(...categories: string[]): void; /** * Enables logging of one or more error categories. The default category is "general". */ static disable(...categories: string[]): void; static wrap(error: AxiosResponse | AlBaseError | Error | string | any, message: string): AlWrappedError; static describe(error: any, verbose?: boolean): AlErrorDescriptor; /** * Utility function to descend into arbitrarily nested and potentially circular data, replacing any AIMS tokens * or Authorization headers with a redaction marker. * * If `trimCircularity` is true (default), circular references will be flattened with a special string, making the object * suitable for serialization. */ static redact(info: any, trimCircularity?: boolean, circular?: any[]): any; protected static prepare(): AlCabinet; protected static getErrorDescription(error: any, verbose?: boolean): string; protected static compactErrorResponse(response: AxiosResponse): any; protected static compactWrappedError(error: AlWrappedError): any; protected static compactError(error: Error, type?: string, otherProperties?: any): any; protected static consolidateWrappedErrorDescription(error: AlWrappedError | Error | AxiosResponse | string, verbose?: boolean): string; /** * Matches a response TODO(kjn): hook this up to the content service, when it's available, and use content from there instead of here :) */ protected static getResponseDescription(response: AxiosResponse, verbose?: boolean): string; }