Exception filters — WebSockets · NestJS

Refuse a message the socket way: WsException with a message or an object, what every other error becomes on the wire, and a filter that sends the HTTP API's exceptions to a socket with their message instead of hiding them.

What you will learn

Read the theory for Exception filters

All WebSockets lessons

All NestJS courses

loading types…

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