Re: uncaught exception in callback
Yoann Padioleau <[email protected]>
| Newsgroups | gmane.comp.lang.ocaml.lib.gtk |
|---|---|
| Message-ID | <[email protected]> |
Yoann Padioleau <[email protected]> writes: > Hi, > > Is it possible to desactivate the capture of exceptions in > lablgtk code ? I want to debug my code and see where one > my exception is launched but I can not get the backtrace > because of lablgtk which does not let the exception > unwind to the top. I saw this in gtkSignal.ml let user_handler = ref raise ... let connect ~(sgn : ('a, _) t) ~callback ?(after=false) (obj : 'a obj) = let callback argv = let old = push_callback () in begin try sgn.marshaller callback argv with exn -> try !user_handler exn with exn -> Printf.eprintf "In callback for signal %s, uncaught exception: %s\n" sgn.name (Printexc.to_string exn); flush stderr end; if pop_callback old then emit_stop_by_name obj ~name:sgn.name in connect_by_name obj ~name:sgn.name ~callback:(Closure.create callback) ~after Would it be possible to have instead a global flag that the user/programmer can set to control this behaviour ? Or maybe just change a little the code to something like this instead: let user_handler = ref (fun exn -> Printf.eprintf "In callback for signal %s, uncaught exception: %s\n" sgn.name (Printexc.to_string exn); flush stderr; raise exn ) let connect ~(sgn : ('a, _) t) ~callback ?(after=false) (obj : 'a obj) = let callback argv = let old = push_callback () in begin try sgn.marshaller callback argv with exn -> !user_handler exn end; if pop_callback old then emit_stop_by_name obj ~name:sgn.name in connect_by_name obj ~name:sgn.name ~callback:(Closure.create callback) ~after