How to pass error object to socket.io callback <p>I am using callbacks with socket.io </p> <p>Client code :</p> <pre><code>socket.emit('someEvent', {data:1}, function(err, result) { console.log(err.message); }); </code></pre> <p>Server code :</p> <pre><code>socket.on('someEvent', function(data, callback) { callback(new Error('testing error')); }); </code></pre> <p>With the above code the client side always prints out <code>undefined</code>. If I change the server side code to the following I can see the error message.</p> <pre><code>socket.on('someEvent', function(data, callback) { callback({message:'testing error'}); }); </code></pre> <p>I can pass my own custom objects to the client just fine, just not the error object. Any ideas?</p>