From 9416e0552d6e8fef07f548cd7dc30c52bb753bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Thu, 14 Jul 2022 11:43:41 +0200 Subject: [PATCH] error_handler: only show not found for `Not_Found For all other error status codes we just pass on the suggested response. --- lib/builder_web.ml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/builder_web.ml b/lib/builder_web.ml index 41ba400..07ed2d6 100644 --- a/lib/builder_web.ml +++ b/lib/builder_web.ml @@ -675,14 +675,18 @@ let error_template error _debug_info suggested_response = let referer = Option.bind error.Dream.request (fun req -> Dream.header req "referer") in - let html = - if is_iframe_page ~req:error.Dream.request then - Views.viz_not_found - else - Views.page_not_found ~target ~referer - in - Dream.set_header suggested_response "Content-Type" Dream.text_html; - Dream.set_body suggested_response @@ string_of_html html; - Lwt.return suggested_response + match Dream.status suggested_response with + | `Not_Found -> + let html = + if is_iframe_page ~req:error.Dream.request then + Views.viz_not_found + else + Views.page_not_found ~target ~referer + in + 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