1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:57:44 +00:00

LibWeb: Make ExceptionOr capable of holding all error types in the spec

The WebIDL spec specifies a few "simple" exception types in addition to
the DOMException type, let's support all of those.
This allows functions returning ExceptionOr<T> to throw regular
javascript exceptions (as limited by the webidl spec) by returning a
`DOM::SimpleException { DOM::SimpleExceptionType::T, "error message" }`
which is pretty damn cool :^)
This commit is contained in:
Ali Mohammad Pur 2021-06-27 00:17:13 +04:30 committed by Linus Groh
parent bda19a9ff3
commit fd72597999
4 changed files with 77 additions and 35 deletions

View file

@ -224,7 +224,7 @@ ExceptionOr<void> Document::set_body(HTML::HTMLElement& new_body)
if (existing_body) {
auto replace_result = existing_body->parent()->replace_child(new_body, *existing_body);
if (replace_result.is_exception())
return NonnullRefPtr<DOMException>(replace_result.exception());
return replace_result.exception();
return {};
}
@ -234,7 +234,7 @@ ExceptionOr<void> Document::set_body(HTML::HTMLElement& new_body)
auto append_result = document_element->append_child(new_body);
if (append_result.is_exception())
return NonnullRefPtr<DOMException>(append_result.exception());
return append_result.exception();
return {};
}