import AggregateError from '@flex-development/aggregate-error-ponyfill'; import { NullishString } from '@flex-development/tutils'; import { ExceptionDataDTO } from '../dtos'; import { ExceptionClassName, ExceptionCode, ExceptionId } from '../enums'; import { AxiosError, ExceptionJSON, FirebaseError, NextError } from '../interfaces'; import { ExceptionData, ExceptionErrors } from '../types'; /** * @file Exceptions - Exception Base Class * @module exceptions/exceptions/Exception */ /** * Custom error class. * * @template T - Error type * * @extends {AggregateError} */ export default class Exception extends AggregateError { /** * @readonly * @property {ExceptionErrors} errors - Aggregated errors */ readonly errors: ExceptionErrors; /** * @readonly * @property {'Exception'} name - Constructor name */ readonly name: 'Exception'; /** * @readonly * @property {ExceptionClassName} className - Associated CSS class name */ readonly className: ExceptionClassName; /** * @readonly * @property {ExceptionCode} code - HTTP error response status code */ readonly code: ExceptionCode; /** * @readonly * @property {ExceptionData} data - Custom error data */ readonly data: ExceptionData; /** * @readonly * @property {ExceptionId} id - HTTP error response status code name */ readonly id: ExceptionId; /** * Instantiates a new Exception. * * @param {ExceptionCode} [code=500] - HTTP error response status code * @param {NullishString} [message=DEM] - Exception message * @param {ExceptionDataDTO} [data={}] - Custom error data * @param {ExceptionErrors} [data.errors] - Single error or group of errors * @param {string} [data.message] - Custom message. Overrides `message` * @param {string} [stack=''] - Error stack */ constructor(code?: ExceptionCode, message?: NullishString, data?: ExceptionDataDTO, stack?: string); /** * Finds a HTTP error response status name by status code. * * If the name isn't found, `INTERNAL_SERVER_ERROR` will be returned. * * @param {ExceptionCode} code - HTTP status code * @return {ExceptionId} - Name of exception or empty string */ static findIdByCode(code: ExceptionCode): ExceptionId; /** * Returns `500` if `code` is not a valid `Exception` status code. * * @param {any} [code] - Possible status code * @return {ExceptionCode} Exception status code */ static formatCode(code?: any): ExceptionCode; /** * Converts an `AxiosError` into an `Exception`. * * @template T - Error type * * @param {AxiosError} error - HTTP error to transform * @return {Exception} AxiosError as Exception */ static fromAxiosError(error: AxiosError): Exception; /** * Converts a FirebaseError into an Exception. * * @template T - Error type * * @param {FirebaseError} error - Firebase error to transform * @return {Exception} FirebaseError as Exception */ static fromFirebaseError(error: FirebaseError): Exception; /** * Converts a Next.js error into an Exception. * * @template T - Error type * * @param {NextError} error - Next.js page error to transform * @return {Exception} NextError as Exception */ static fromNextError(error: NextError): Exception; /** * Returns a JSON object representing the current Exception. * * To help identify JSON versions of `Exception` class objects, the `data` * property will have an `isExceptionJSON` property added to it. * * @return {Readonly>} JSON object representing Exception */ toJSON(): Readonly>; } //# sourceMappingURL=base.exception.d.ts.map