Open Bug 1250223 Opened 8 years ago Updated 9 months ago

When using promise-style WebExtension interfaces, validation errors throw instead of returning a rejected promise

Categories

(WebExtensions :: General, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: aswan, Unassigned)

References

Details

(Whiteboard: triaged)

The code that does type, format, etc checking on parameters passed into WebExtensions functions always throws, but this is awkward when using the promise-style interfaces.

As an example, the url field in the options passed to browser.downloads.download() must be in the "url" format.  But that means that this code is broken since download() will throw, and neither the then() or catch() handler will ever be invoked:

browser.downloads.download({url: someURL})
  .then(id => ..)
  .catch(err => ..)

:kmag points out that if the parameters are so hopelessly broken that we can't even figure out if there is a valid callback, then the only option is to throw.  But lets make this better for the case outlined above.
Assignee: nobody → aswan
Priority: -- → P3
Whiteboard: triaged
Component: WebExtensions: Untriaged → WebExtensions: General
This also affects chrome-like callback code.

E. g. |chrome.notifications.create| throws if trying to use buttons, while it should instead be executing the callback with chrome.extension.lastError set (for chrome compatibility)
I'm not actually working on this so un-assigning.  At this point, it may be too late to make any changes if people are writing code that depends on the current behavior...
Assignee: aswan → nobody
It's never too late to fix bugs
Product: Toolkit → WebExtensions
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.