nest: Emitting an error event throws an exception
Bug Report
Current behaviour
If you emit an error event in a web socket gateway:
socket.emit('error', 'un-authorized');
it throws an unhandled exception like this:
UnhandledPromiseRejectionWarning: Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('un-authorized')
The same thing happens even if we throw a WsException:
throw new WsException('un-authorized');
The error doesn’t get forwarded to the client. The client is set to listen to this error event, get the message and show it to the user.
Expected behavior
Forwarding the error event to the client which triggers the on error event.
Environment
Nest version: 6.7.1
For Tooling issues:
- Node version: 10.16.0
- Platform: Mac
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (2 by maintainers)
@izio38 Thanks I tried to listen to the
exceptionevent in both client and server. Still nothing. I just need to get the error message to the front end (client) 🙂@izio38 Sure you can have a look at this repo: https://github.com/THPubs/nest-ws