This repository was archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
dialog: cancel errors with "Possibly unhandled rejection" when no catch exists #10369
Copy link
Copy link
Closed
Labels
P5: nice to haveThese issues will not be fixed without community contributions.These issues will not be fixed without community contributions.needs: demoA CodePen demo or GitHub repository is needed to demonstrate the reproduction of the issueA CodePen demo or GitHub repository is needed to demonstrate the reproduction of the issueresolution: works as expectedThe functionality works as designed and documented.The functionality works as designed and documented.
Description
Actual Behavior:
What is the issue? *When calling$mdDialog.show()and the user press cancel, a message is shown in the console:"Possibly unhandled rejection: undefined"What is the expected behavior?
Recently Angular has started to log possibly unhandled rejections commit
This is a discussion of how to handle the console errors.
- Give a reason in the reject (Possibly unhandled rejection: User pressed cancel)
- Do not use reject as a way of dismissing the dialog. According to MDN rejected promises are "almost" the same as throwing an error. This implies that a user clicking cancel is "almost" the same as handling them by throwing an exception.
- Add a global unhandled rejection event handler to silence all errors (including actual errors):
app.config(['$qProvider', function ($qProvider) {
$qProvider.errorOnUnhandledRejections(false);
}]);
- Add a catch block to the promise
$mdDialog.show({...})
.then(confirmUserAction)
.catch(() => {}); // or angular.noop
What are your thoughts?
Thanks
CodePen (or steps to reproduce the issue): *
Details:
Create a dialog with the $mdDialog.show(). Then press the cancel button on the dialog.
Angular Versions: *
Angular Version:1.6.1Angular Material Version:1.1.1
Additional Information:
Browser Type: *ChromeBrowser Version: *55OS: *MacOSStack Traces:
mennya, webpartisan, ches151, uriva, fetters5 and 19 more
Metadata
Metadata
Assignees
Labels
P5: nice to haveThese issues will not be fixed without community contributions.These issues will not be fixed without community contributions.needs: demoA CodePen demo or GitHub repository is needed to demonstrate the reproduction of the issueA CodePen demo or GitHub repository is needed to demonstrate the reproduction of the issueresolution: works as expectedThe functionality works as designed and documented.The functionality works as designed and documented.