3 ms·
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
by homami 6y ago
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
}
- mdouglass 6y agoIt probably fires as an async error, I'd expect this would log it (if inserted at the end of the try block): socket.onerror = (...args) => console.log('async error', ...args)
- homami 6y agosocket.onerror event happens for both cases. But there does not seem to be any difference between the error object that is passed to the these handlers.