0
我以前的错误处理功能:堆栈跟踪错误处理程序,并承诺错误处理程序
function onError(message, source, lineno, colno, error) { sendRequestToSendMail(arguments) }
window.onerror = onError
我也承诺异步任务,我想赶上他们的异常。我不需要重复自己喜欢的:
doSomething1()
.then(doSomething2(), onError)
.then(doSomething3(), onError)
.then(doSomething4(), onError)
如何为所有承诺(如window.onError)实现全局错误处理程序?