question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mandatory reject param?

See original GitHub issue

Hi there!

I’m upgrading my code to v4, and I saw that the new reject(dismiss) Promise is mandatory to avoid browser errors. If I do not set a dismiss function, I get the following error in Chrome:

Uncaught (in promise) cancel

Would be possible to make this reject optional? Sometimes we just want to close the popup if the user hits cancel, and not show a new swal to confirm that the user clicked cancel successfully.

If I code an empty dismiss function just to avoid this error, ES6 linters will fire up to not create empty functions, and the code would not be accepted for deployment.

Best regards, Rafael.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
limontecommented, Jun 27, 2016

@samturrell I implemented your suggestion in v4.0.6 https://jsfiddle.net/limon/2ya7akjq/

Thank you Sam, with your help we finally found the solution for this issue.

5reactions
samturrellcommented, Jun 27, 2016

The only way i can really see this being resolved is with an opt-in solution such as

Promise.prototype.done = function() {
    return this.catch(function() {
        // Silence is golden.
        // Catch promise rejections silently.
    });
};

And then swal().done() to suppress the error.

There is no way to fix this without using a non-native promise implementation where we can suppress the error internally.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Promise.reject() - JavaScript - MDN Web Docs
The Promise.reject() method returns a Promise object that is rejected with a given reason.
Read more >
Reject parameters not in Param() statement - Stack Overflow
How do I tell the powershell parameter handling machinery that the only valid parameters are the ones I explicitly state in the Param...
Read more >
Optional parameters should reject `undefined` parameter values
node built/local/tsc.js --strictNullChecks index.ts index.ts(5,3): error TS2345: Argument of type 'undefined' is not assignable to parameter ...
Read more >
ActionController::Parameters - Rails API
Action Controller Parameters Allows you to choose which attributes should be ... The former is used to mark parameters as required. ... Alias...
Read more >
7.12 Reject Statements | Stan Reference Manual
The Stan reject statement provides a mechanism to report errors or problematic values encountered during program execution and either halt processing or reject...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found