let catch_print_exceptions f x =
try f x
with
e ->
let s =
match e with
Failure s
| Sys_error s -> s
| Unix.Unix_error (e,s1,s2) ->
Printf.sprintf "%s: %s %s" (Unix.error_message e) s1 s2
| e -> Printexc.to_string e
in
Cam_hooks.error_message s