diff --git a/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp b/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp index 07b66a6754..6338e859af 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp +++ b/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -263,10 +264,14 @@ JS::GCPtr load_document(Optional navigati auto& realm = document->realm(); if (navigation_params->response->body()) { - auto process_body = [document](ByteBuffer bytes) { - if (!parse_document(*document, bytes)) { - dbgln("FIXME: Load html page with an error if parsing failed."); - } + auto process_body = [document, url = navigation_params->response->url().value()](ByteBuffer bytes) { + if (parse_document(*document, bytes)) + return; + document->remove_all_children(true); + auto error_html = load_error_page(url).release_value_but_fixme_should_propagate_errors(); + auto parser = HTML::HTMLParser::create(document, error_html, "utf-8"); + document->set_url(AK::URL("about:error")); + parser->run(); }; auto process_body_error = [](auto) {