Capture error in JavaScript promise

Sprinkle

Posted on
Dec 23 2015

Hi,

In a client side JavaScript app, what is the recommended way to capture unhandled exception in Promise.

It seems that what the document suggested

Raygun.init('yourApiKey').attach();

is not enough, and unhandled exception in promise are not captured.

Any recommendation on how to capture unhandled exception in Promise?


Daniel

Posted on
Jan 11 2016

Hey,

Here's a Stackoverflow article with a few details - http://stackoverflow.com/questions/28001722/how-to-catch-uncaught-exception-in-promise

In short though, it looks like it's not possible to capture errors thrown inside of promise functions using the standard exception handlers.

You should be able to capture them yourself at the end of your promise chains though and send them through using raygun.send(error);

Hope this helps - let me know if I can help any further

Regards, Daniel


Gregor

Posted on
Aug 24 2016

Seems like you can these days with the "unhandledrejection" event. Any chance this could be added to RaygunJS?


Reply