How to catch uncaught exception in Promise

后端 未结 5 1522
悲哀的现实
悲哀的现实 2020-12-04 17:22

Is there any way to globally catch all exceptions including Promise exceptions. Example:

    window.onerror = function myErrorHandler(errorMsg, url, lineNumb         


        
5条回答
  •  醉话见心
    2020-12-04 18:05

    In Node.js, you can use:

    process.on('unhandledRejection', (reason, promise) => {
      console.error(`Uncaught error in`, promise);
    });
    

提交回复
热议问题