Wrap the WebSocket.send in a try-catch.