package opam-core

  1. Overview
  2. Docs
val fatal : exn -> unit

To use when catching default exceptions: ensures we don't catch fatal errors like C-c. try-with should _always_ (by decreasing order of preference):

  • either catch specific exceptions
  • or re-raise the same exception (preferably with Exn.finalise)
  • or call this function on the caught exception
val register_backtrace : exn -> unit

Register a backtrace for when you need to process a finalizer (that internally uses exceptions) and then re-raise the same exception. To be printed by pretty_backtrace.

val pretty_backtrace : exn -> string

Return a pretty-printed backtrace

val finalise : exn -> (unit -> unit) -> 'a

Runs the given finaliser, then reraises the given exception, while preserving backtraces (when the OCaml version permits, e.g. >= 4.05.0)

val finally : (unit -> unit) -> (unit -> 'a) -> 'a

Execute the given continuation, then run the finaliser before returning the result. If an exception is raised, call finalise with the given finaliser.


Innovation. Community. Security.