mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
feat: add CanGc argument to Error::to_jsval (#36014)
* feat: add CanGc argument to Error::to_jsval Signed-off-by: Arya Nair <aryaajitnair@gmail.com> * feat: pass CanGc to gen_type_error Signed-off-by: Arya Nair <aryaajitnair@gmail.com> * fix: linting issues Signed-off-by: Arya Nair <aryaajitnair@gmail.com> --------- Signed-off-by: Arya Nair <aryaajitnair@gmail.com>
This commit is contained in:
parent
6807a6e532
commit
94d12de7fd
11 changed files with 45 additions and 24 deletions
|
@ -275,18 +275,30 @@ pub(crate) fn throw_constructor_without_new(cx: SafeJSContext, name: &str) {
|
|||
}
|
||||
|
||||
pub(crate) trait ErrorToJsval {
|
||||
fn to_jsval(self, cx: SafeJSContext, global: &GlobalScope, rval: MutableHandleValue);
|
||||
fn to_jsval(
|
||||
self,
|
||||
cx: SafeJSContext,
|
||||
global: &GlobalScope,
|
||||
rval: MutableHandleValue,
|
||||
can_gc: CanGc,
|
||||
);
|
||||
}
|
||||
|
||||
impl ErrorToJsval for Error {
|
||||
/// Convert this error value to a JS value, consuming it in the process.
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
fn to_jsval(self, cx: SafeJSContext, global: &GlobalScope, rval: MutableHandleValue) {
|
||||
fn to_jsval(
|
||||
self,
|
||||
cx: SafeJSContext,
|
||||
global: &GlobalScope,
|
||||
rval: MutableHandleValue,
|
||||
can_gc: CanGc,
|
||||
) {
|
||||
match self {
|
||||
Error::JSFailed => (),
|
||||
_ => unsafe { assert!(!JS_IsExceptionPending(*cx)) },
|
||||
}
|
||||
throw_dom_exception(cx, global, self, CanGc::note());
|
||||
throw_dom_exception(cx, global, self, can_gc);
|
||||
unsafe {
|
||||
assert!(JS_IsExceptionPending(*cx));
|
||||
assert!(JS_GetPendingException(*cx, rval));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue