* [Caml-list] Printexc.register_printer without catch
@ 2012-04-13 9:12 Matthias Puech
2012-04-13 9:18 ` Gabriel Scherer
2012-04-13 9:33 ` Mark Shinwell
0 siblings, 2 replies; 6+ messages in thread
From: Matthias Puech @ 2012-04-13 9:12 UTC (permalink / raw)
To: caml-list
Hello,
Is there a way to change printing of uncaught exceptions in the toplevel
and in (native/bytecode, 3.12) compiled code without wrapping the whole
code in a try ... with or in Printexc.catch?
Printexc.catch's documentation says it is deprecated and that the
runtime system should be able to print exceptions the way they were
registered with Printexc.register_printer, yet
# Printexc.register_printer begin function Not_found -> Some "hello" | _
-> None end;;
# raise Not_found;;
Exception: Not_found.
(* I would expect it to respond [Exception: hello] *)
Do I miss something here?
Thanks in advance,
-m
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Printexc.register_printer without catch
2012-04-13 9:12 [Caml-list] Printexc.register_printer without catch Matthias Puech
@ 2012-04-13 9:18 ` Gabriel Scherer
2012-04-13 9:43 ` Matthias Puech
2012-04-13 9:33 ` Mark Shinwell
1 sibling, 1 reply; 6+ messages in thread
From: Gabriel Scherer @ 2012-04-13 9:18 UTC (permalink / raw)
To: Matthias Puech; +Cc: caml-list
It seems Printexc.register_printer affects the other Printexc.*
functions, not the way the toplevel itself (or the runtime system more
generally) handles uncaught exceptions.
# Printexc.register_printer begin function Not_found -> Some "hello" |
_ -> None end;;
- : unit = ()
# (fun () -> raise Not_found) ();;
Exception: Not_found.
# Printexc.print (fun () -> raise Not_found) ();;
Uncaught exception: hello
Exception: Not_found.
On Fri, Apr 13, 2012 at 11:12 AM, Matthias Puech <puech@cs.unibo.it> wrote:
> Hello,
>
> Is there a way to change printing of uncaught exceptions in the toplevel and
> in (native/bytecode, 3.12) compiled code without wrapping the whole code in
> a try ... with or in Printexc.catch?
>
> Printexc.catch's documentation says it is deprecated and that the runtime
> system should be able to print exceptions the way they were registered with
> Printexc.register_printer, yet
>
> # Printexc.register_printer begin function Not_found -> Some "hello" | _ ->
> None end;;
> # raise Not_found;;
> Exception: Not_found.
>
> (* I would expect it to respond [Exception: hello] *)
>
> Do I miss something here?
> Thanks in advance,
> -m
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Printexc.register_printer without catch
2012-04-13 9:12 [Caml-list] Printexc.register_printer without catch Matthias Puech
2012-04-13 9:18 ` Gabriel Scherer
@ 2012-04-13 9:33 ` Mark Shinwell
1 sibling, 0 replies; 6+ messages in thread
From: Mark Shinwell @ 2012-04-13 9:33 UTC (permalink / raw)
To: Matthias Puech; +Cc: caml-list
On Fri, Apr 13, 2012 at 11:12:27AM +0200, Matthias Puech wrote:
> Is there a way to change printing of uncaught exceptions in the
> toplevel and in (native/bytecode, 3.12) compiled code without
> wrapping the whole code in a try ... with or in Printexc.catch?
I don't believe so. However, I have nearly finished a patch to enable this, so
the feature may appear soon if I can get sufficient buy-in from the other
developers.
Mark
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Printexc.register_printer without catch
2012-04-13 9:18 ` Gabriel Scherer
@ 2012-04-13 9:43 ` Matthias Puech
2012-04-13 9:52 ` Jérémie Dimino
0 siblings, 1 reply; 6+ messages in thread
From: Matthias Puech @ 2012-04-13 9:43 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 2389 bytes --]
Ok so it seems Printexc is not the way to go... Can you make sense out
of this sentence in catch's documentation then?
"This function is deprecated: the runtime system is now able to print
uncaught exceptions as precisely as|Printexc.catch|does"
In the toplevel, exceptions are printed in a sensible way, i.e. their
arguments is printed as far as it can go respecting abstract types:
# type t = A | B;;
# exception Bla of t;;
# raise (Bla A);;
Exception: Bla A.
Also it honors my #install_printer when printing arguments.
If I compile the same code, I get:
Fatal error: exception Exc.Bla(0)
It seems there is a very ad-hoc, type-unaware exception handler in
compiled code (byterun/printexc.c:caml_format_exception?) that can't be
changed and I was hoping Printexc would do that for me. It seems not;
so, no other way to change the global catcher?
Thanks,
-m
Le 04/13/2012 11:18 AM, Gabriel Scherer a écrit :
> It seems Printexc.register_printer affects the other Printexc.*
> functions, not the way the toplevel itself (or the runtime system more
> generally) handles uncaught exceptions.
>
> # Printexc.register_printer begin function Not_found -> Some "hello" |
> _ -> None end;;
> - : unit = ()
> # (fun () -> raise Not_found) ();;
> Exception: Not_found.
> # Printexc.print (fun () -> raise Not_found) ();;
> Uncaught exception: hello
> Exception: Not_found.
>
>
> On Fri, Apr 13, 2012 at 11:12 AM, Matthias Puech<puech@cs.unibo.it> wrote:
>> Hello,
>>
>> Is there a way to change printing of uncaught exceptions in the toplevel and
>> in (native/bytecode, 3.12) compiled code without wrapping the whole code in
>> a try ... with or in Printexc.catch?
>>
>> Printexc.catch's documentation says it is deprecated and that the runtime
>> system should be able to print exceptions the way they were registered with
>> Printexc.register_printer, yet
>>
>> # Printexc.register_printer begin function Not_found -> Some "hello" | _ ->
>> None end;;
>> # raise Not_found;;
>> Exception: Not_found.
>>
>> (* I would expect it to respond [Exception: hello] *)
>>
>> Do I miss something here?
>> Thanks in advance,
>> -m
>>
>> --
>> Caml-list mailing list. Subscription management and archives:
>> https://sympa-roc.inria.fr/wws/info/caml-list
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>>
>
[-- Attachment #2: Type: text/html, Size: 5042 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Printexc.register_printer without catch
2012-04-13 9:43 ` Matthias Puech
@ 2012-04-13 9:52 ` Jérémie Dimino
2012-04-13 14:04 ` Matthias Puech
0 siblings, 1 reply; 6+ messages in thread
From: Jérémie Dimino @ 2012-04-13 9:52 UTC (permalink / raw)
To: Matthias Puech; +Cc: caml-list
Le Fri, 13 Apr 2012 11:43:17 +0200,
Matthias Puech <puech@cs.unibo.it> a écrit :
> It seems there is a very ad-hoc, type-unaware exception handler in
> compiled code (byterun/printexc.c:caml_format_exception?) that can't
> be changed and I was hoping Printexc would do that for me. It seems
> not; so, no other way to change the global catcher?
There is a report about this:
http://caml.inria.fr/mantis/view.php?id=5040
Cheers,
--
Jérémie
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Printexc.register_printer without catch
2012-04-13 9:52 ` Jérémie Dimino
@ 2012-04-13 14:04 ` Matthias Puech
0 siblings, 0 replies; 6+ messages in thread
From: Matthias Puech @ 2012-04-13 14:04 UTC (permalink / raw)
To: caml-list
Le 04/13/2012 11:52 AM, Jérémie Dimino a écrit :
> There is a report about this:
> http://caml.inria.fr/mantis/view.php?id=5040 Cheers,
Of course, it's Stéphane's :) ... and with a patch!
Thanks for the pointer,
Cheers,
-m
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-04-14 16:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-13 9:12 [Caml-list] Printexc.register_printer without catch Matthias Puech
2012-04-13 9:18 ` Gabriel Scherer
2012-04-13 9:43 ` Matthias Puech
2012-04-13 9:52 ` Jérémie Dimino
2012-04-13 14:04 ` Matthias Puech
2012-04-13 9:33 ` Mark Shinwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).