Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty printer pour exceptions #2464

Closed
vicuna opened this issue May 22, 2000 · 1 comment
Closed

Pretty printer pour exceptions #2464

vicuna opened this issue May 22, 2000 · 1 comment

Comments

@vicuna
Copy link

vicuna commented May 22, 2000

Original bug ID: 123
Reporter: administrator
Assigned to: @xclerc
Status: closed (set by @xavierleroy on 2011-05-29T10:20:27Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 3.11.2+dev
Category: ~DO NOT USE (was: OCaml general)
Has duplicate: #4477

Bug description

Full_Name: fabrice le fessant
Version: 3.00
OS: linux...
Submission from: cremant.inria.fr (128.93.8.143)

printexc.mli:

val install_printer : (exn -> string option) -> unit
(* Install a pretty printer for some exceptions. The printer returns
[None] if it can not pretty-print the exception, or [Some s]
with the string corresponding to the exception. *)

printexc.ml:

let printers = ref []
let install_printer p = printers := p :: !printers

let to_string = function
....
| x ->
let rec iter list =
match list with
[] -> raise Not_found
| p :: tail ->
try
match p x with
None -> raise Not_found
| Some s -> s
with _ -> iter tail
in
try
iter !printers
with _ ->
let x = Obj.repr x in
let constructor = (Obj.magic(Obj.field (Obj.field x 0) 0) : string) in
constructor ^ (fields x)

@vicuna
Copy link
Author

vicuna commented Sep 16, 2009

Comment author: @xclerc

support for custom exception printers has been committed in the 'release311' branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant