Skip to content
Advertisement

Rejecting a promise throws “Uncaught (in promise)”

I’m using promises to handle to handle a modal dialog: resolved when the user press the OK button, rejected when cancelled or closed.

To resolve and dismiss the modal I use this methods:

JavaScript

And when cancel button fires this method within the modal:

JavaScript

Everything is working fine and the modal hides, but a console error is logged with this description and stack:

JavaScript

It is weird because the modal is dismissed anyway, and this error is not shown on all modals I use, just in some of them. Resolving does not produce this kind error.

Advertisement

Answer

You have to catch it to prevent the error

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement