Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
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

@bjarketrux

Description

@bjarketrux

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.
  1. Give a reason in the reject (Possibly unhandled rejection: User pressed cancel)
  2. 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.
  3. Add a global unhandled rejection event handler to silence all errors (including actual errors):
app.config(['$qProvider', function ($qProvider) {
$qProvider.errorOnUnhandledRejections(false);
}]);
  1. 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.1
  • Angular Material Version: 1.1.1

Additional Information:

  • Browser Type: * Chrome
  • Browser Version: * 55
  • OS: * MacOS
  • Stack Traces:

Metadata

Metadata

Assignees

No one assigned

    Labels

    P5: nice to haveThese issues will not be fixed without community contributions.needs: demoA CodePen demo or GitHub repository is needed to demonstrate the reproduction of the issueresolution: works as expectedThe functionality works as designed and documented.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions