【问题标题】:UnhandledPromiseRejectionWarning when calling ionic cordova build --release android调用 ionic cordova build --release android 时出现 UnhandledPromiseRejectionWarning
【发布时间】:2018-08-06 14:01:18
【问题描述】:

每当我尝试使用 ionic cordova build --release android:

(node:1512) UnhandledPromiseRejectionWarning: 未处理的承诺 拒绝。此错误源于在异步内部抛出 没有 catch 块的函数,或者通过拒绝一个承诺 不使用 .catch() 处理。 (拒绝 ID:1)(节点:1512)[DEP0018] DeprecationWarning:不推荐使用未处理的承诺拒绝。在 未来,未处理的承诺拒绝将终止 具有非零退出代码的 Node.js 进程。

感谢您的回答!

【问题讨论】:

    标签: ionic-framework


    【解决方案1】:

    当你调用一个promise并且没有添加一个catch块时,这个警告就会发生。当 promise 调用被拒绝时,将调用 catch 块。

    例如:

    var foo = function () {
        fooPromise
            .then(function (res) {
                // Do something with the response of the promise
            })
            .catch(function (err) {
                // handle the error 
            });
    };
    

    查看 Javascript 文档了解更多信息:here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-19
      • 2018-05-12
      • 2022-08-15
      • 1970-01-01
      • 1970-01-01
      • 2020-03-20
      相关资源
      最近更新 更多