package stdcompat

  1. Overview
  2. Docs
include module type of struct include Printexc end
type t = exn = ..

The type of exception values.

val to_string_default : exn -> string

Printexc.to_string_default e returns a string representation of the exception e, ignoring all registered exception printers.

  • since 4.09
val use_printers : exn -> string option

Printexc.use_printers e returns None if there are no registered printers and Some s with else as the resulting string otherwise.

  • since 4.09

Raw backtraces

type raw_backtrace_entry = private int

A raw_backtrace_entry is an element of a raw_backtrace.

Each raw_backtrace_entry is an opaque integer, whose value is not stable between different programs, or even between different runs of the same binary.

A raw_backtrace_entry can be converted to a usable form using backtrace_slots_of_raw_entry below. Note that, due to inlining, a single raw_backtrace_entry may convert to several backtrace_slots. Since the values of a raw_backtrace_entry are not stable, they cannot be marshalled. If they are to be converted, the conversion must be done by the process that generated them.

Again due to inlining, there may be multiple distinct raw_backtrace_entry values that convert to equal backtrace_slots. However, if two raw_backtrace_entrys are equal as integers, then they represent the same backtrace_slots.

  • since 4.12.0
val raw_backtrace_entries : Printexc.raw_backtrace -> raw_backtrace_entry array
  • since 4.12.0

Current call stack

Uncaught exceptions

val default_uncaught_exception_handler : exn -> Printexc.raw_backtrace -> unit

Printexc.default_uncaught_exception_handler prints the exception and backtrace on standard error output.

  • since 4.11

Manipulation of backtrace information

These functions are used to traverse the slots of a raw backtrace and extract information from them in a programmer-friendly format.

val backtrace_slots_of_raw_entry : raw_backtrace_entry -> Printexc.backtrace_slot array option

Returns the slots of a single raw backtrace entry, or None if this entry lacks debug information.

Slots are returned in the same order as backtrace_slots: the slot at index 0 is the most recent call, raise, or primitive, and subsequent slots represent callers.

  • since 4.12

Raw backtrace slots

Exception slots

type raw_backtrace = Printexc.raw_backtrace
type backtrace_slot = Printexc.backtrace_slot
type location = Printexc.location = {
  1. filename : string;
  2. line_number : int;
  3. start_char : int;
  4. end_char : int;
}
val to_string : exn -> string
module Slot = Printexc.Slot
type raw_backtrace_slot = Printexc.raw_backtrace_slot
val raise_with_backtrace : exn -> raw_backtrace -> 'a
val get_raw_backtrace_next_slot : Printexc.raw_backtrace_slot -> Printexc.raw_backtrace_slot option
val set_uncaught_exception_handler : (exn -> Printexc.raw_backtrace -> unit) -> unit
val backtrace_slots : Printexc.raw_backtrace -> Printexc.backtrace_slot array option
val raw_backtrace_length : Printexc.raw_backtrace -> int
val get_raw_backtrace_slot : Printexc.raw_backtrace -> int -> Printexc.raw_backtrace_slot
val convert_raw_backtrace_slot : Printexc.raw_backtrace_slot -> Printexc.backtrace_slot
val exn_slot_id : exn -> int
val exn_slot_name : exn -> string
val get_callstack : int -> raw_backtrace
val get_raw_backtrace : unit -> Printexc.raw_backtrace
val print_raw_backtrace : out_channel -> Printexc.raw_backtrace -> unit
val raw_backtrace_to_string : Printexc.raw_backtrace -> string
val print_backtrace : out_channel -> unit
val get_backtrace : unit -> string
val record_backtrace : bool -> unit
val backtrace_status : unit -> bool
val register_printer : (exn -> string option) -> unit
val print : ('a -> 'b) -> 'a -> 'b
val catch : ('a -> 'b) -> 'a -> 'b
OCaml

Innovation. Community. Security.