Error structure
A structure to have code-error pairs.
To keep the same pattern as Nest when throwing an exception, let's have the fields statusCode
with the code of the status and error
with the name of this status. Let's then create the file common/util/http-error.util. Here, we'll define status
and error
pairs to type the errors in a standard and safe way.
To only allow errors in this format, we can create an interface...
...to state that the HttpError
must follow its contract.
Going back to the filter, we can extract these two fields from the aproppriate error.
The next step is to extract the entity name from the message.
Last updated