diff --git a/src/lib_error_monad/error_monad.ml b/src/lib_error_monad/error_monad.ml index fd66f785a..5c0c43fca 100644 --- a/src/lib_error_monad/error_monad.ml +++ b/src/lib_error_monad/error_monad.ml @@ -507,8 +507,6 @@ let () = Data_encoding.(obj1 (req "msg" string)) (function | Exn (Failure msg) -> Some msg - | Exn (Unix.Unix_error (err, fn, _)) -> - Some ("Unix error in " ^ fn ^ ": " ^ Unix.error_message err) | Exn exn -> Some (Printexc.to_string exn) | _ -> None) (fun msg -> Exn (Failure msg)) diff --git a/src/lib_stdlib_unix/lwt_utils_unix.ml b/src/lib_stdlib_unix/lwt_utils_unix.ml index 2d9d5f34c..8e1aed807 100644 --- a/src/lib_stdlib_unix/lwt_utils_unix.ml +++ b/src/lib_stdlib_unix/lwt_utils_unix.ml @@ -7,7 +7,19 @@ (* *) (**************************************************************************) -open Error_monad +let () = + register_error_kind + `Temporary + ~id:"unix_error" + ~title:"Unix error" + ~description:"An unhandled unix exception" + ~pp:Format.pp_print_string + Data_encoding.(obj1 (req "msg" string)) + (function + | Exn (Unix.Unix_error (err, fn, _)) -> + Some ("Unix error in " ^ fn ^ ": " ^ Unix.error_message err) + | _ -> None) + (fun msg -> Exn (Failure msg)) let read_bytes ?(pos = 0) ?len fd buf = let len = match len with None -> Bytes.length buf - pos | Some l -> l in