bindings: Convert certain Exceptions into Promise rejections (#32923)

* Impl promise exception to rejection for methods

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Impl promise exception to rejection for getters

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Impl promise exception to rejection for static methods

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Add tests for exception to rejection

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Expectations

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2024-08-03 14:58:37 +02:00 committed by GitHub
parent fd83281657
commit f3bec0aed3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 291 additions and 20 deletions

View file

@ -1084,6 +1084,29 @@ impl TestBindingMethods for TestBinding {
stringMember: Some(s2),
}
}
fn MethodThrowToRejectPromise(&self) -> Fallible<Rc<Promise>> {
Err(Error::Type("test".to_string()))
}
fn GetGetterThrowToRejectPromise(&self) -> Fallible<Rc<Promise>> {
Err(Error::Type("test".to_string()))
}
fn MethodInternalThrowToRejectPromise(&self, _arg: u64) -> Rc<Promise> {
unreachable!("Method should already throw")
}
}
#[allow(non_snake_case)]
impl TestBinding {
pub fn StaticThrowToRejectPromise(_: &GlobalScope) -> Fallible<Rc<Promise>> {
Err(Error::Type("test".to_string()))
}
pub fn StaticInternalThrowToRejectPromise(_: &GlobalScope, _arg: u64) -> Rc<Promise> {
unreachable!("Method should already throw")
}
}
#[allow(non_snake_case)]