signature EXN structure Exn : EXN
The structure Exn provides first-class access to raised exceptions, which allows controlling the generation of exception backtraces for debugging purposes.
See also: General
signature EXN = sig exttype exn type t = exn type packet val name : exn -> string val message : exn -> string val fromPacket : packet -> exn val update : packet * exn -> packet val catch : (packet -> 'a) -> (unit -> 'a) -> 'a val reraise : packet -> 'a val dumpTrace : packet -> unit end
The type of exceptions. Equivalent to the toplevel exn type.
The type of raised exception packets. Along with the exception proper, a packet carries information about its origin and a trace of its propagation history.
Returns a name for the exception ex. Equivalent to General.exnName ex.
Returns a message corresponding to exception ex. Equivalent to General.exnMessage ex.
Retrieves the exception contained in the packet p.
Constructs a new packet by replacing the exception in packet p by ex.
Applies f() and returns its result. If an exception is raised, handler is invoked with the respective packet and its result is returned. The following equivalence holds:
catch ((fn match) o fromPacket) (fn () => exp) = exp handle match
Re-raises the packet p, without dropping its backtrace. Semantically equivalent to raise fromPacket p, but a backtrace of the raised exception will, when caught with catch, include the history of p.
Writes the backtrace of packet p to some implementation-dependent output (e.g. stderr). This function is provided solely for debugging convenience, the format and the destination of the dump is left unspecified.