【发布时间】:2020-11-18 01:02:38
【问题描述】:
在nodejs中,我们可以这样处理异常:
process.on('uncaughtException', (err, origin) => {
fs.writeSync(
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`
);
});
setTimeout(() => {
console.log('This will still run.');
}, 500);
// Intentionally cause an exception, but don't catch it.
nonexistentFunc();
console.log('This will not run.');
deno 的替代品是什么? 我知道有 window.onunload,但它不处理错误
【问题讨论】:
标签: node.js typescript exception deno