Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript on uncaught exception

// NODE JS
process.on('uncaughtException', function (error) {
    // Handle the error
});
        

// Browser
window.onunhandledrejection = event => {
  console.warn(`UNHANDLED PROMISE REJECTION: ${event.reason}`);
};

window.onerror = function(message, source, lineNumber, colno, error) {
  console.warn(`UNHANDLED ERROR: ${error.stack}`);
};

// OR

window.addEventListener('error', function(event) { ... })
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #uncaught #exception
ADD COMMENT
Topic
Name
7+9 =