@aequum/exceptions
v0.27.15
Published
aequum common exceptions collection
Readme
aequum common exceptions collection
This package provides a set of rich, descriptive and detailed exceptions interfaces, classes and types to have an standard way to handle show errors and providing the right information to the user or developer when an error occurs in the application.
Design
Each exception class must have:
- A text
codefor error, we useERR_prefix and uppercase snake case. - An HTTP status code for the error is available but isn't
mandatory by default it uses a
500error code. - A human readable
messagethat describes the error. - An
inputobject or struct to show the input that caused the error, on some complex cases it have an structured object with more details, as in case ofValidationException. - Also one of the base constructor arguments are the
causeof the error if it derives from another exception, this is useful to trace the error back to its origin.
Classes
Base:
BaseException: The base class for all exceptions.
Authorization:
Unauthorized: Exception for unauthorized access.
Data:
- `DuplicateEntryException': Exception for duplicate entries.
NotFoundException: Exception for not found resources.
Validation:
ValidationException: Validation exception, for input objects, this exception have an structured output forinputproperty, representing the input property validated and it's corresponding error messages.
Interfaces
ValidationableException: Interface withasValidationExceptionmethod to convert an error/exception/validation object into a validation exception.
