improve error messages in main somewhat

This commit is contained in:
tali 2024-02-01 14:08:27 -05:00
parent e2967fabd9
commit 4cbd4421ce
1 changed files with 13 additions and 1 deletions

View File

@ -1,3 +1,5 @@
include (val Logging.sublogs Server.logger "Main")
let min_level =
match Sys.getenv_opt "LOG_LEVEL" |> Option.map String.uppercase_ascii with
| Some "TRACE" -> Logging.TRACE
@ -72,4 +74,14 @@ let config : Server.config = {
}
let () =
Printexc.register_printer
(function
| Unix.Unix_error (eno, who, _) -> Some (Fmt.str "%s: %s" who (Unix.error_message eno))
| Failure msg -> Some ("internal error: " ^ msg)
| Invalid_argument who -> Some ("internal error: invalid argumnet: " ^ who)
| _ -> None);
try
Lwt_main.run @@ Server.run config
with exn ->
error (fun m -> m "%a" Fmt.exn exn);
exit 1