Open Bug 967946 Opened 12 years ago Updated 3 years ago

Add a convenience function to create an exception from a nsresult

Categories

(Core :: DOM: Core & HTML, defect, P5)

x86_64
Linux
defect

Tracking

()

People

(Reporter: nsm, Unassigned)

Details

A lot of the new APIs require Promises to be rejected on error. If this error is due to underlying XPCOM stuff, I'd like a nice way to get an exception object from the nsresult. The XPCOM machinery that allows functions to return an NS_ERROR_FAILURE and have a nice exception thrown in JS, but without actually throwing it. Then you could just promise->MaybeReject(cx, val) the exception. I'm not sure how to actually do this.
See dom/bindings/Exceptions.cpp, in particular mozilla::dom::Throw and ThrowExceptionObject. We could refactor that to have a method that creates the Value and returns it that you could use. Throw() and company would then call that method and then JS_SetPendingException on the result.
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.