matchbox icon indicating copy to clipboard operation
matchbox copied to clipboard

Error Callback Arguments

Open theronic opened this issue 10 years ago • 11 comments

I need to be able to handle specific failed Firebase writes due to permissions or missing Internet, please.

theronic avatar Sep 21 '15 11:09 theronic

Is it not possible to catch the exceptions in this case? Otherwise the API needs to change

crisptrutski avatar Sep 21 '15 12:09 crisptrutski

Won't the exception be thrown asynchronously?

Could you show me a simple example of how to catch a write exception that could be caused by either a permission error, or downed connection?

theronic avatar Sep 21 '15 12:09 theronic

Do you need to be able to track it back to a particular write? I think that'll be hard with the exception.

We could enrich the exceptions as a stop gap, and I'll think about explicit error callback for the rewrite

As for providing sample code, will see if I have time this evening to knock out something from you

crisptrutski avatar Sep 22 '15 08:09 crisptrutski

Yes, otherwise I can't tell the user if a particular action (like a form submit that triggers a write) failed and if they need to retry. Or maybe the write callback can be called with an additional error argument?

Thanks!

theronic avatar Sep 22 '15 08:09 theronic

@pate Sorry, I haven't had time to look at this yet. Have you been able to work around it for now?

crisptrutski avatar Oct 05 '15 20:10 crisptrutski

@pate have you figured this out?

I'm on the javascript API, .on seems to take a cancelCallback. My naive try is to pass in the regular callback as a cancelCallback too. https://github.com/Quantisan/matchbox/commit/5501ad557395aef7e4b4960582c0557d609bfc77 But that doesn't work at all. I'm getting a ref.key is not a function or something.

Quantisan avatar Nov 10 '15 17:11 Quantisan

My use case is that I just need the async channel for listen-to< to return. Right now if there's an error, the channel doesn't return.

Quantisan avatar Nov 10 '15 21:11 Quantisan

@Quantisan in your example is the listener being called at least? it's probably just tripping over the specifics of that decorated listener, which is build a tuple of the key/value, and making sure that value is Clojure(Script) data.

I have never actually used cancelCallback - the docs mention it being for when the user does not have permissions to a path. Is this your use case or are you perhaps interested in .onDisconnect / matchbox.core/on-disconnect?

crisptrutski avatar Nov 12 '15 22:11 crisptrutski

@crisptrutski yes, my user might not have permission to access the data. Thanks for the tip. I'll figure this out next week.

Quantisan avatar Nov 12 '15 22:11 Quantisan

@Quantisan have you progressed with this at all? I'd like to see if you found a solution before I go messing up the library 😝

burn2delete avatar May 03 '16 17:05 burn2delete

@flyboarder frankly, it's been too long... so just go ahead. Thanks for checking!

Quantisan avatar May 03 '16 17:05 Quantisan