diff --git a/src/Tiny_httpd_dir.ml b/src/Tiny_httpd_dir.ml index b3fb6fb7..ad048449 100644 --- a/src/Tiny_httpd_dir.ml +++ b/src/Tiny_httpd_dir.ml @@ -95,7 +95,7 @@ let vfs_of_dir (top : string) : vfs = let read_file_content f = let ic = Unix.(openfile (top // f) [ O_RDONLY ] 0) in - Tiny_httpd_stream.of_fd ic + Tiny_httpd_stream.of_fd_close_noerr ic let create f = let oc = open_out_bin (top // f) in @@ -330,8 +330,12 @@ let add_vfs_ ~on_fs ~top ~config ~vfs:((module VFS : VFS) as vfs) ~prefix server ~headers:(mime_type @ [ "Etag", Lazy.force mtime ]) ~code:200 stream with e -> - S.Response.fail ~code:500 "error while reading file: %s" - (Printexc.to_string e) + let bt = Printexc.get_raw_backtrace () in + let msg = Printexc.to_string e in + Log.error (fun k -> + k "dir.get failed: %s@.%s" msg + (Printexc.raw_backtrace_to_string bt)); + S.Response.fail ~code:500 "error while reading file: %s" msg )) else S.add_route_handler server ~meth:`GET (route ()) (fun _ _ ->