diff options
author | Linus Groh <mail@linusgroh.de> | 2020-04-12 19:32:35 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-13 00:47:53 +0200 |
commit | 62d0fa5af8c83623b422b28acb402f647350e051 (patch) | |
tree | bd785227d17b858886ae04e9649fd1c0347fe9dc /Libraries/LibWeb | |
parent | ad230e8839b65938a9ebd5aea6e98e3ce74bb09d (diff) | |
download | serenity-62d0fa5af8c83623b422b28acb402f647350e051.zip |
LibWeb: Use specific error classes when throwing exceptions
Generally:
- interpreter.throw_exception<JS::Error>("TypeError", "Message");
+ interpreter.throw_exception<JS::TypeError>("Message");
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r-- | Libraries/LibWeb/Bindings/DocumentWrapper.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/WindowObject.cpp | 8 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/Libraries/LibWeb/Bindings/DocumentWrapper.cpp b/Libraries/LibWeb/Bindings/DocumentWrapper.cpp index 6e9b76176c..9a5bcb60c5 100644 --- a/Libraries/LibWeb/Bindings/DocumentWrapper.cpp +++ b/Libraries/LibWeb/Bindings/DocumentWrapper.cpp @@ -64,7 +64,7 @@ static Document* document_from(JS::Interpreter& interpreter) if (!this_object) return {}; if (StringView("DocumentWrapper") != this_object->class_name()) { - interpreter.throw_exception<JS::Error>("TypeError", "That's not a DocumentWrapper, bro."); + interpreter.throw_exception<JS::TypeError>("That's not a DocumentWrapper, bro."); return {}; } return &static_cast<DocumentWrapper*>(this_object)->node(); diff --git a/Libraries/LibWeb/Bindings/WindowObject.cpp b/Libraries/LibWeb/Bindings/WindowObject.cpp index bc47d02bf6..0e6a70de86 100644 --- a/Libraries/LibWeb/Bindings/WindowObject.cpp +++ b/Libraries/LibWeb/Bindings/WindowObject.cpp @@ -78,7 +78,7 @@ static Window* impl_from(JS::Interpreter& interpreter) return nullptr; } if (StringView("WindowObject") != this_object->class_name()) { - interpreter.throw_exception<JS::Error>("TypeError", "That's not a WindowObject, bro."); + interpreter.throw_exception<JS::TypeError>("That's not a WindowObject, bro."); return nullptr; } return &static_cast<WindowObject*>(this_object)->impl(); @@ -108,7 +108,7 @@ JS::Value WindowObject::set_interval(JS::Interpreter& interpreter) if (!callback_object) return {}; if (!callback_object->is_function()) - return interpreter.throw_exception<JS::Error>("TypeError", "Not a function"); + return interpreter.throw_exception<JS::TypeError>("Not a function"); impl->set_interval(*static_cast<JS::Function*>(callback_object), arguments[1].to_i32()); return JS::js_undefined(); } @@ -125,7 +125,7 @@ JS::Value WindowObject::set_timeout(JS::Interpreter& interpreter) if (!callback_object) return {}; if (!callback_object->is_function()) - return interpreter.throw_exception<JS::Error>("TypeError", "Not a function"); + return interpreter.throw_exception<JS::TypeError>("Not a function"); i32 interval = 0; if (interpreter.argument_count() >= 2) @@ -147,7 +147,7 @@ JS::Value WindowObject::request_animation_frame(JS::Interpreter& interpreter) if (!callback_object) return {}; if (!callback_object->is_function()) - return interpreter.throw_exception<JS::Error>("TypeError", "Not a function"); + return interpreter.throw_exception<JS::TypeError>("Not a function"); return JS::Value(impl->request_animation_frame(*static_cast<JS::Function*>(callback_object))); } diff --git a/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp b/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp index 58d4ce9ac0..a0dd72bd4b 100644 --- a/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp +++ b/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp @@ -51,7 +51,7 @@ static XMLHttpRequest* impl_from(JS::Interpreter& interpreter) if (!this_object) return nullptr; if (StringView("XMLHttpRequestWrapper") != this_object->class_name()) { - interpreter.throw_exception<JS::Error>("TypeError", "This is not an XMLHttpRequest object"); + interpreter.throw_exception<JS::TypeError>("This is not an XMLHttpRequest object"); return nullptr; } return &static_cast<XMLHttpRequestWrapper*>(this_object)->impl(); |