1Printexc(3)                      OCaml library                     Printexc(3)
2
3
4

NAME

6       Printexc - Facilities for printing exceptions.
7

Module

9       Module   Printexc
10

Documentation

12       Module Printexc
13        : sig end
14
15
16       Facilities for printing exceptions.
17
18
19
20
21
22
23
24       val to_string : exn -> string
25
26
27       Printexc.to_string e returns a string representation of the exception e
28       .
29
30
31
32
33       val print : ('a -> 'b) -> 'a -> 'b
34
35
36       Printexc.print fn x applies fn to x and returns  the  result.   If  the
37       evaluation  of  fn x raises any exception, the name of the exception is
38       printed on standard error output, and the exception  is  raised  again.
39       The  typical  use is to catch and report exceptions that escape a func‐
40       tion application.
41
42
43
44
45       val catch : ('a -> 'b) -> 'a -> 'b
46
47
48       Printexc.catch fn x is similar to Printexc.print , but aborts the  pro‐
49       gram  with  exit  code  2  after printing the uncaught exception.  This
50       function is deprecated:  the  runtime  system  is  now  able  to  print
51       uncaught  exceptions  as  precisely  as Printexc.catch does.  Moreover,
52       calling Printexc.catch makes it harder to track  the  location  of  the
53       exception  using  the debugger or the stack backtrace facility.  So, do
54       not use Printexc.catch in new code.
55
56
57
58
59       val print_backtrace : Pervasives.out_channel -> unit
60
61
62       Printexc.print_backtrace oc prints an exception backtrace on the output
63       channel  oc  .   The  backtrace  lists  the program locations where the
64       most-recently raised exception was raised and where it  was  propagated
65       through function calls.
66
67
68
69
70       val get_backtrace : unit -> string
71
72
73       Printexc.get_backtrace  ()  returns a string containing the same excep‐
74       tion backtrace that Printexc.print_backtrace would print.
75
76
77
78
79       val record_backtrace : bool -> unit
80
81
82       Printexc.record_backtrace b turns recording of exception backtraces  on
83       (if  b  = true ) or off (if b = false ).  Initially, backtraces are not
84       recorded, unless the b flag is given to the program through the  OCAML‐
85       RUNPARAM variable.
86
87
88
89
90       val backtrace_status : unit -> bool
91
92
93       Printexc.backtrace_status()  returns  true  if exception backtraces are
94       currently recorded, false if not.
95
96
97
98
99       val register_printer : (exn -> string option) -> unit
100
101
102       Printexc.register_printer fn registers fn as an exception printer.  The
103       printer  should  return  None  if  it  does not know how to convert the
104       passed exception, and Some s with s the resulting string if it can con‐
105       vert the passed exception.  When converting an exception into a string,
106       the printers will be invoked in the reverse order  of  their  registra‐
107       tions,  until  a  printer  returns  a  Some s value (if no such printer
108       exists, the runtime will use a generic printer).
109
110
111
112
113
114
115OCamldoc                          2017-03-22                       Printexc(3)
Impressum