Reputation: 1573
I am writing a multiplayer webgame using socket.io and phaser and am having some trouble debugging my application. The problem is that whenever a piece of javascript code crashes within a socket.io listener function, the program will crash silently and hide the error message from the console. For reference, I am talking about code in places like this:
var socket = io('http://localhost');
socket.on('news', function (data) {
//Error ridden code
});
To clarify, it is not only socket.io related errors that are hidden, but any arbitrary error that occurs within one of those listeners (e.g a type error, accessing a property of undefined object etc.). This is problematic as a large bulk of the game's code occurs in response to socket messages from the server.
My question is - how do I get socket.io to stop censoring this information in the console?
Upvotes: 0
Views: 292
Reputation: 128
Please use the following code to perform error handling:
socket.on('error', function (err) {
console.log(err);
});
Upvotes: 1