aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/error.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2023-05-30 10:32:33 -0400
committerJosh Matthews <josh@joshmatthews.net>2023-05-30 10:32:33 -0400
commit56a8237ef4b9cfcf6081c61349e2994a57d2093c (patch)
tree1b53b0b5b5f69bf6f805732834192befc0239fc8 /components/script/dom/bindings/error.rs
parent43f5b4899bd15569bd9dfb4b3bd3f10307cb893c (diff)
downloadservo-56a8237ef4b9cfcf6081c61349e2994a57d2093c.tar.gz
servo-56a8237ef4b9cfcf6081c61349e2994a57d2093c.zip
Throw type error when calling DOM constructor without new.
Diffstat (limited to 'components/script/dom/bindings/error.rs')
-rw-r--r--components/script/dom/bindings/error.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/components/script/dom/bindings/error.rs b/components/script/dom/bindings/error.rs
index 9356918ccc1..87df14d0544 100644
--- a/components/script/dom/bindings/error.rs
+++ b/components/script/dom/bindings/error.rs
@@ -312,6 +312,12 @@ pub unsafe fn throw_invalid_this(cx: *mut JSContext, proto_id: u16) {
throw_type_error(cx, &error);
}
+pub unsafe fn throw_constructor_without_new(cx: *mut JSContext, name: &str) {
+ debug_assert!(!JS_IsExceptionPending(cx));
+ let error = format!("{} constructor: 'new' is required", name);
+ throw_type_error(cx, &error);
+}
+
impl Error {
/// Convert this error value to a JS value, consuming it in the process.
pub unsafe fn to_jsval(