Response setup
With everything ready, the response can be set up and sent.
With the status
, error
and message
in hand, it's time to setup the response
. We can chain the following methods:
status()
- Sets thestatus
of theresponse
json()
- Defines the returnedbody
With this, we return an exception following the same pattern as Nest.
We have finished our first exception filter! We can then activate it globally in the DatabaseModule
.
Commit - Creating the not found exception filter
After this, we can search our code and, wherever we find something like this:
We may replace it with the following:
Only do this when the exception thrown is a NotFoundException
.
Commit - Cleaning find one calls
Last updated