UNPKG

@hexadrop/error

Version:

Hexagonal architecture utils library

46 lines (44 loc) 1.2 kB
/** * The base class for all domain errors. * * @public */ declare abstract class DomainError extends Error { readonly code: string; /** * Returns the average of two numbers. * * @param name - The name of the error * @param message - The error message * @param code - [Optional] The error code. Must follow the next Regexp `/[A-Z][A-Z][A-Z]\((\d{3}|\d{6})\)/`. * For example FNL(123) or RPA(435678) */ protected constructor(name: string, message: string, code: string); /** * Gets the numeric part of the error code. * * @returns {number} The numeric part of the error code. */ get errorCode(): number; } /** * Class representing an InvalidErrorCodeError. * @extends DomainError */ declare class InvalidErrorCodeError extends DomainError { /** * Creates a new InvalidErrorCodeError. */ constructor(); } /** * Class representing an EmptyErrorCodeError. * @extends DomainError */ declare class EmptyErrorCodeError extends DomainError { /** * Creates a new EmptyErrorCodeError. */ constructor(); } export { EmptyErrorCodeError, InvalidErrorCodeError, DomainError as default };