You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 7156 Reporter:@mjambon Assigned to:@diml Status: assigned (set by @mshinwell on 2016-12-08T14:08:42Z) Resolution: open Priority: normal Severity: minor Version: 4.02.3 Category: toplevel Tags: junior_job Monitored by: mfp @diml@hcarty
Bug description
Uncaught exceptions reported by the ocaml toplevel are printed as if no custom printer was registered. Programs compiled with ocamlc or ocamlopt behave as desired and consult the custom printers to print uncaught exceptions.
martin@mj2 ~/tmp $ echo > .ocamlinit
martin@mj2 ~/tmp $ ocaml
OCaml version 4.02.3
# Printexc.register_printer (fun e -> Some "yo");;
- : unit = ()
# raise Exit;;
Exception: Pervasives.Exit.
#
When compiled with ocamlc or ocamlopt however, the exception is printed using the custom printers:
martin@mj2 ~/tmp $ cat toto.ml
Printexc.register_printer (fun e -> Some "yo");;
raise Exit;;
martin@mj2 ~/tmp $ ocamlc -c toto.ml
martin@mj2 ~/tmp $ ./toto
Fatal error: exception yo
The text was updated successfully, but these errors were encountered:
Indeed. Although I don't think we can just use [Printexc.to_string directly] as it won't print things as good when no printer is registered. Maybe we need a [Printexc.to_string_opt] function.
fixes#7156
Two new functions exposed:
```ocaml
val to_string_default: exn -> string
(** [Printexc.to_string_default e] returns a string representation of the
exception [e], ignoring all registered exception printers.
@SInCE 4.09
*)
val use_printers: exn -> string option
(** [Printexc.use_printers e] returns [None] if there are no registered
printers and [Some s] with else as the resulting string otherwise.
@SInCE 4.09
*)
```
Original bug ID: 7156
Reporter: @mjambon
Assigned to: @diml
Status: assigned (set by @mshinwell on 2016-12-08T14:08:42Z)
Resolution: open
Priority: normal
Severity: minor
Version: 4.02.3
Category: toplevel
Tags: junior_job
Monitored by: mfp @diml @hcarty
Bug description
Uncaught exceptions reported by the ocaml toplevel are printed as if no custom printer was registered. Programs compiled with ocamlc or ocamlopt behave as desired and consult the custom printers to print uncaught exceptions.
When compiled with ocamlc or ocamlopt however, the exception is printed using the custom printers:
The text was updated successfully, but these errors were encountered: