Closed Bug 1791292 Opened 3 years ago Closed 3 years ago

Propagate nsresult to JS exception in ESM APIs

Categories

(Core :: XPConnect, task)

task

Tracking

()

RESOLVED FIXED
107 Branch
Tracking Status
firefox107 --- fixed

People

(Reporter: arai, Assigned: arai)

References

Details

Attachments

(1 file)

If the target file is not found ChromeUtils.import throws DOM exception with nsresult set as result property, and it's used in the following case:

https://searchfox.org/mozilla-central/rev/249ef0d85120097b6f34fceb0bea501bfe900b6c/toolkit/components/backgroundtasks/BackgroundTasksManager.jsm#94-95,98-102

try {
  const taskModule = ChromeUtils.import(URI);
...
} catch (ex) {
  if (ex.result != Cr.NS_ERROR_FILE_NOT_FOUND) {
    throw ex;
  }
}

bug 1778089 changed the ESM APIs to report human-friendly error message with the URL of the module, but it unintentionally removed the result property.

we'd better reporting both the human-friendly error and the result property'.

See Also: → 1778089

the DOM's Exception has message field, so if that can be directly set from loader, it would also work.

https://searchfox.org/mozilla-central/rev/6d7704caae2a61b0101bdb67481a80af20376663/dom/webidl/DOMException.webidl#53,57-58

interface Exception {
...
  [BinaryName="messageMoz"]
  readonly attribute DOMString               message;
Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/51eb5e963b65 Expose nsresult for file-not-found error. r=jonco
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 107 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: