Hacker News new | ask | show | jobs
by homami 2222 days 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
    }
1 comments

It 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)
socket.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.