1 (* Copyright 2001, 2002 b8_bavard, b8_fee_carabine, INRIA *)
3 This file is part of mldonkey.
5 mldonkey is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 mldonkey is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mldonkey; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 (* Module [Printexc2]: facilities for printing exceptions *)
22 val to_string
: exn
-> string
23 (* [Printexc2.to_string e] returns a string representation of
26 val printers
: (exn
-> string) list
ref
29 val print
: ('a
-> 'b
) -> 'a
-> 'b
30 (* [Printexc2.print fn x] applies [fn] to [x] and returns the result.
31 If the evaluation of [fn x] raises any exception, the
32 name of the exception is printed on standard error output,
33 and the exception is raised again.
34 The typical use is to catch and report exceptions that
35 escape a function application. *)
37 val register_exn
: (exn
-> string) -> unit
38 (*d [register_exn printer] registers a printer for user-defined
39 exceptions. [printer] is a function which takes an exception as argument
40 and converts it to a string. If it cannot convert the exception, it should
43 val catch
: string -> ('a
-> unit) -> 'a
-> unit
44 val catch2
: string -> ('a
-> 'b
-> unit) -> 'a
-> 'b
-> unit
45 (*d [catch msg f x] executes the function [f] and returns unit. If an
46 exception is raised during the execution of [f], the message [msg] is
47 printed on standard output with the exception using [printexn], and unit
50 val vcatchexn
: string -> (unit -> 'a
) -> 'a
option
51 (*d [vcatchexn msg f] executes the function [f] and returns (Some [v]) if
52 [v] is the value returned by [f]. If an
53 exception is raised during the execution of [f], the message is printed
54 on standard output with the exception using [printexn], and