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.
Each exception class must have:
- A text
code
for 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
500
error code. - A human readable
message
that describes the error. - An
input
object 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
cause
of the error if it derives from another exception, this is useful to trace the error back to its origin.
-
BaseException
: The base class for all exceptions.
-
Unauthorized
: Exception for unauthorized access.
- `DuplicateEntryException': Exception for duplicate entries.
-
NotFoundException
: Exception for not found resources.
-
ValidationException
: Validation exception, for input objects, this exception have an structured output forinput
property, representing the input property validated and it's corresponding error messages.
-
ValidationableException
: Interface withasValidationException
method to convert an error/exception/validation object into a validation exception.