gpt4 book ai didi

node.js - 未处理的PromiseRejection警告: Unclear which file or line the warning is for

转载 作者:太空宇宙 更新时间:2023-11-04 01:59:51 25 4
gpt4 key购买 nike

我收到了几个与此类似的错误:

(node:30892) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): SyntaxError

从这些问题( What is Unhandled Promise RejectionNodeJS UnhandledPromiseRejectionWarning )来看,这些警告似乎是由于 .then 链之后的 promise 上没有 .catch 引起的

但是,这些警告没有问题所在的文件或行号。有什么办法可以找到这个/缩小范围吗?

最佳答案

您可以捕获 unhandled promise rejection warning ,并使用给定的数据来了解它发生的位置。

process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
});
<小时/>

这个家伙here告诉我们:

enter image description here

关于node.js - 未处理的PromiseRejection警告: Unclear which file or line the warning is for,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46424522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com