Firebase 3, AngularFire 2 Cannot Catch Error with

457 views
Skip to first unread message

ch...@lead-web.com

unread,
Sep 2, 2016, 4:25:17 PM9/2/16
to Firebase Google Group

Hi,

Firebase v3.2.1
AngularFire 2.0.1


I try to set my firebase database, but I got an error but I cannot catch it! No console log message appear!

Error: Firebase.set failed: First argument contains undefined in property 'products.xxxxx.longDescFR'


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



Is it the right way to catch a reject/fail promise with set firebase?

Any idea?

Chuck

Jacob Wenger

unread,
Sep 2, 2016, 4:32:50 PM9/2/16
to fireba...@googlegroups.com
Hey Chuck,

When possible, the Firebase SDK will throw a synchronous error instead of an asynchronous error through the promise. This is because it is much more obvious to see this error than if we returned it in a promise chain and you had no catch() set up. The issue here is that you are passing an object productList which has at least one key whose value is undefined. The correct thing to do here is to validate that productList is a valid Firebase object before calling set(). You should do this in your own code.

Cheers,
Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/c6c6fd20-a32b-483e-b717-a55fd854cd72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kato Richardson

unread,
Sep 2, 2016, 4:33:27 PM9/2/16
to Firebase Google Group
Hi Chuck,

That's the correct way to catch an error. I suspect you don't have a complete enough repro here for us to be any help. You've mentioned AngularFire2, but that's straight SDK code and not related to the OSS lib, and it may depend on the error, which you haven't provided here either.

☼, Kato

On Fri, Sep 2, 2016 at 1:12 PM, <ch...@lead-web.com> wrote:

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/c6c6fd20-a32b-483e-b717-a55fd854cd72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Reply all
Reply to author
Forward
0 new messages