/[mldonkey]/mldonkey/src/utils/cdk/printexc2.ml
ViewVC logotype

Diff of /mldonkey/src/utils/cdk/printexc2.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by mldonkey, Fri Jan 30 06:11:07 2004 UTC revision 1.3 by spiralvoice, Thu Jul 7 00:25:46 2005 UTC
# Line 19  Line 19 
19    
20  open Printf2;;  open Printf2;;
21  open Printf  open Printf
22      
23  let locfmt =  let locfmt =
24    Obj.magic (match Sys.os_type with    Obj.magic (match Sys.os_type with
25    | "MacOS" -> "File \"%s\"; line %d; characters %d to %d ### %s"    | "MacOS" -> "File \"%s\"; line %d; characters %d to %d ### %s"
# Line 83  let print fct arg = Line 83  let print fct arg =
83      raise x      raise x
84    
85  let register_exn f = printers := f :: !printers  let register_exn f = printers := f :: !printers
86      
87  let catch s f x =  let catch s f x =
88    try f x with    try f x with
89      e ->      e ->
90        lprintf "Uncaught exception in %s: %s" s (to_string e);        lprintf_nl "Uncaught exception in %s: %s" s (to_string e)
91        lprint_newline ()  
     
92  let catch2 s f x y =  let catch2 s f x y =
93    try f x y with    try f x y with
94      e ->      e ->
95        lprintf "Uncaught exception in %s: %s" s (to_string e);        lprintf_nl "Uncaught exception in %s: %s" s (to_string e)
96        lprint_newline ()  
     
97  let vcatchexn s f =  let vcatchexn s f =
98    try Some (f ()) with    try Some (f ()) with
99      e ->      e ->
100        lprintf "Uncaught exception in %s: %s" s (to_string e);        lprintf_nl "Uncaught exception in %s: %s" s (to_string e);
       lprint_newline ();  
101        None        None
102    
103  let _ =  let _ =
104    register_exn (fun e ->    register_exn (fun e ->
105        match e with        match e with
106          Unix.Unix_error (e, f, arg) ->          Unix.Unix_error (e, f, arg) ->
107            Printf.sprintf "%s failed%s: %s" f (if arg = "" then "" else            Printf.sprintf "%s failed%s: %s" f (if arg = "" then "" else
108                "on " ^ arg) (Unix.error_message e)                "on " ^ arg) (Unix.error_message e)
109            | _ -> raise e            | _ -> raise e
110    )    )

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26