-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
angular2-modal: EXCEPTION: Uncaught (in promise): undefined #188
Comments
+1
|
This exception is thrown when dismissing the dialog, if a reject function was not supplemented. The exception doesn't really cause any problems. But if you want to get rid of it, from a user perspective, you should make it like:
From the perspective of the library developer, @shlomiassaf could fix it by checking if the reject function actually exists before trying to call it. |
the workaround seems to be working by adding I hope @shlomiassaf will fix it. |
I believe it's not possible to check if there is a reject handler for the promise. A better approach would adding a context config for not rejecting the promise, although I understand that DialogRef shouldn't care about context properties. This means that all context would inherit from a BaseContext. Paging @shlomiassaf for his view |
I'll look into a possible solution. What about wrapping the resolve/reject call in a try/catch? |
AFAIK a try/catch wouldn't help with unhandled rejections, since they don't fire a exception on the |
Wouldn't it work if we just say: if (reject !== undefined) What do you think? On 23 Sep 2016 02:45, "Júlio César" [email protected] wrote:
|
What do you think about this?
|
@kisdaniel @JulioC You're completely right, I though the promise itself will throw and not the handlers inside, my bad. I have another proposal, jus before rejecting register a catch handler.
Usually this is wrong, the library shouldn't mess with the promise chain. Each handler from the ROOT is a different chain so I don't see any issues, To illustrate:
The last Thoughts? |
see the suggested PR |
I overlooked the fact that the promise could have any amount of catch handlers. Your solution looks fine, as long this handler is only registered when the dialog is dismissed. |
I still get this when I close the modal (First time) |
Indeed, it will still throw if you set a resolve callback, but no reject: modal.open(MyModal);
.then(dialog => {}); I believe the only possible solution would stop rejecting the promise if the modal is dismissed. Maybe add a |
It would indeed be a very annoying breaking change because most people don't check the result in their Confirm dialogs. In addition the exception is not that problematic. It never caused any bugs for me at least, so I don't think it is worth a breaking change |
Hi guys, I am also getting this same error. Is there any work around without any breaking changes?? |
You can still use the workaround above, always provide a reject callback: modal.open(MyModal)
.then(dialog => {})
.catch(() => {}); // this is the workaround |
#223 fixed my issue. thanks |
This is still an issue. @JulioC workaround works |
same problem in angular 5.1.1 |
I found the problem, need to pass the second param to "then": dont works: works:
|
@micheltank the second parameter is supposed to be optional. |
Hi please try to implement this way for dialog
|
I get the following error when I close the modal alert:
Sample code:
Dependencies:
The text was updated successfully, but these errors were encountered: