Add two functions to get the exception slot id and name from an exception value.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/raise_variants@14240 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
0f6f367ad4
commit
be3c4d6882
|
@ -171,3 +171,16 @@ let register_printer fn =
|
|||
|
||||
|
||||
external get_callstack: int -> raw_backtrace = "caml_get_current_callstack"
|
||||
|
||||
|
||||
let exn_slot x =
|
||||
let x = Obj.repr x in
|
||||
if Obj.tag x = 0 then Obj.field x 0 else x
|
||||
|
||||
let exn_slot_id x =
|
||||
let slot = exn_slot x in
|
||||
(Obj.obj (Obj.field slot 1) : int)
|
||||
|
||||
let exn_slot_name x =
|
||||
let slot = exn_slot x in
|
||||
(Obj.obj (Obj.field slot 0) : string)
|
||||
|
|
|
@ -112,3 +112,23 @@ val get_callstack: int -> raw_backtrace
|
|||
|
||||
@since 4.01.0
|
||||
*)
|
||||
|
||||
|
||||
(** {6 Exception slots} *)
|
||||
|
||||
val exn_slot_id: exn -> int
|
||||
(** [Printexc.exn_slot_id] returns an integer which uniquely identifies
|
||||
the constructor used to create the exception value [exn]
|
||||
(in the current runtime).
|
||||
|
||||
@since 4.02.0
|
||||
*)
|
||||
|
||||
val exn_slot_name: exn -> string
|
||||
(** [Printexc.exn_slot_id exn] returns the internal name of the constructor
|
||||
used to create the exception value [exn].
|
||||
|
||||
@since 4.02.0
|
||||
*)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue