Can't get the handshake error message in the client

I'm new to node.js and socket.io (latest versions).

I can't find any good enough documentation about handshaking with socket.io 1.0. I know modules exists, but for the sake of understanding socket.io and node.js, I don't want to add other third party modules (like express).

My code work if I accept the handshake, but if I do as said in the socket.io documentation for the error handling, I don't know how to handle that client side. With the developers tools from Chrome, I can see the error in the Network panel from the server to the client, but I can't figure how to get this value in said client and act accordingly.

Handshake error received

Here the piece of code that give me headaches :

io.use(function(socket, next) {
    // some checks
    if (true) {
        next(); // this work
    } else {
        next(new Error('Authentication error'));
    }
}

Maybe I should remove this next(new Error('...')) and just disconnect the socket server side, return something else ? Or maybe I need to add a parameter somewhere (I also want to stay in websocket mode, not polling) server or client side ?

Thanks !

Ok, just found what I'm missing, I just need to add socket.on('error', function ()); client side to catch the error.