sexp_of_t uses a global table of sexp converters. To register a converter for a new
[@@deriving sexp] to its definition. If no suitable converter is
found, the standard converter in
Printexc will be used to generate an atomic
raise, except that the backtrace is not recorded.
format4 are hard to read, so here's an example.
let foobar str = try ... with exn -> Exn.reraisef exn "Foobar is buggy on: %s" str ()
f and afterwards executes
f throws an exception or
handle_uncaught ~exit f catches an exception escaping
f and prints an error
message to stderr. Exits with return code 1 if
true. Otherwise returns
Note that since OCaml 4.02.0, it is not needed to use this at the entry point of your program as the OCaml runtime will do better than this function.
handle_uncaught_and_exit f returns
f (), unless that raises, in which case it
prints the exception and exits nonzero.
Traces exceptions passing through. Useful because in practice backtraces still don't seem to work.
let rogue_function () = if Random.bool () then failwith "foo" else 3 let traced_function () = Exn.reraise_uncaught "rogue_function" rogue_function traced_function ();;
: Program died with Reraised("rogue_function", Failure "foo")
does_raise f returns
f () raises, which is often useful in unit