Files
main.tsmain
What you'll learn
- Throw WsException with a message or an object, and read the exception event the client receives: status, message and the cause
- Know what every other error becomes, an HttpException included: Internal server error, with the details kept on the server
- Write a filter that extends BaseWsExceptionFilter, catches one kind of exception and hands the default filter a WsException
- Bind a filter to a gateway with @UseFilters(), and know a global filter does not reach gateways
Press Run tests to start the app. Its log appears here.Graded endpoints
One client is enough: an exception goes to the client whose message caused it
Bob only watches: none of Ada's errors reach him
A cat that exists is acknowledged as before
A WsException with a message reaches the sender as the exception event: status, message, and the message that caused it
Nothing goes wrong
A WsException with an object sends exactly the object: no status, no cause, so it carries whatever the client needs
The service's NotFoundException would be Internal server error; the filter sends it as a WsException with its own message
A plain Error stays Internal server error: the database's host name never reaches the client, and the filter does not catch it
run the tests first
Frames
Run the tests first.