How does it work in practice? It seems in Chrome these errors cannot be caught try-catch blocks.
try {
var socket = new WebSocket('ws://localhost:808');
}
catch (ex) {
console.log(ex) // control does not reach here
}