Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

errors thrown inside asynchronous functions will act like uncaught errors

const asyncOperation = err => {
  try {
    setTimeout(function() {
      throw err; // will be dropped onto the event queue
      // until the call stack is empty
      // even if this takes longer than
      // a second.
    }, 1000);
  } catch (e) {
    console.log(e) // will not be called
  }
}

asyncOperation('Inner error *!?"$%&#@"')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #errors #thrown #asynchronous #functions #act #uncaught #errors
ADD COMMENT
Topic
Name
5+3 =