firebase 3/AngularFire 2在尝试设置firebase时无法捕获错误

firebase 3/AngularFire 2在尝试设置firebase时无法捕获错误,firebase,firebase-realtime-database,angularfire2,Firebase,Firebase Realtime Database,Angularfire2,Firebase v3.2.1 角火2.0.1 我试图设置firebase,但出现以下错误: Error: Firebase.set failed: First argument contains undefined in property 'products.xxx.longDescFR' 但我无法捕捉错误,没有显示控制台日志 firebase.database().ref('products').set(productList).then(function(ref) { con

Firebase v3.2.1 角火2.0.1

我试图设置firebase,但出现以下错误:

Error: Firebase.set failed: First argument contains undefined in property 'products.xxx.longDescFR'
但我无法捕捉错误,没有显示控制台日志

firebase.database().ref('products').set(productList).then(function(ref) {
      console.log(ref)
    }).catch(function(error) {
      console.log('Failed: ' + error);
    });
你知道如何抓住拒绝/失败承诺吗

Chuck

当服务器上的写入失败时,调用
catch()
子句,因此当安全规则拒绝该操作时

当您传入未定义的
时,客户端上的操作已经失败。您可能可以
尝试捕获它,但最好只检测
未定义的
而不写入:

if (productList) {
    firebase.database().ref('products').set(productList).then(function(ref) {
      console.log(ref)
    }).catch(function(error) {
      console.log('Failed: ' + error);
    });
}
当服务器上的写入失败时,将调用
catch()
子句,因此当安全规则拒绝该操作时

当您传入未定义的
时,客户端上的操作已经失败。您可能可以
尝试捕获它,但最好只检测
未定义的
而不写入:

if (productList) {
    firebase.database().ref('products').set(productList).then(function(ref) {
      console.log(ref)
    }).catch(function(error) {
      console.log('Failed: ' + error);
    });
}

哦,是的,工作!我的productList中没有未定义,但已损坏(Excel=>CVS=÷某些行缺少某些字段)。我把它放在一个尝试捕捉中,我能够捕捉到错误!谢谢哦,是的,工作!我的productList中没有未定义,但已损坏(Excel=>CVS=÷某些行缺少某些字段)。我把它放在一个尝试捕捉中,我能够捕捉到错误!谢谢