error_handler: only show not found for `Not_Found

For all other error status codes we just pass on the suggested response.
This commit is contained in:
Reynir Björnsson 2022-07-14 11:43:41 +02:00
parent f3d8eea546
commit 9416e0552d

View file

@ -675,14 +675,18 @@ let error_template error _debug_info suggested_response =
let referer = let referer =
Option.bind error.Dream.request (fun req -> Dream.header req "referer") Option.bind error.Dream.request (fun req -> Dream.header req "referer")
in in
let html = match Dream.status suggested_response with
if is_iframe_page ~req:error.Dream.request then | `Not_Found ->
Views.viz_not_found let html =
else if is_iframe_page ~req:error.Dream.request then
Views.page_not_found ~target ~referer Views.viz_not_found
in else
Dream.set_header suggested_response "Content-Type" Dream.text_html; Views.page_not_found ~target ~referer
Dream.set_body suggested_response @@ string_of_html html; in
Lwt.return suggested_response Dream.set_header suggested_response "Content-Type" Dream.text_html;
Dream.set_body suggested_response @@ string_of_html html;
Lwt.return suggested_response
| _ ->
Lwt.return suggested_response
module Link = Link module Link = Link