diff --git a/src/bin/http_of_dir.ml b/src/bin/http_of_dir.ml
index 66236a24..3acad633 100644
--- a/src/bin/http_of_dir.ml
+++ b/src/bin/http_of_dir.ml
@@ -48,8 +48,13 @@ let html_list_dir ~top ~parent d : string =
Array.iter
(fun f ->
if not @@ contains_dot_dot (d // f) then (
- Printf.bprintf body "
%s %s \n"
- (d // f) f (if Sys.is_directory (top // d // f) then "[dir]" else "");
+ let fpath = top // d // f in
+ if not @@ Sys.file_exists fpath then (
+ Printf.bprintf body " %s [invalid file]\n" f
+ ) else (
+ Printf.bprintf body " %s %s \n"
+ (d // f) f (if Sys.is_directory fpath then "[dir]" else "")
+ );
)
)
entries;