Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Looking up exceptions in a dictionary
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Fabrice Le Fessant <fabrice.le_fessant@i...>
Subject: Re: [Caml-list] Looking up exceptions in a dictionary

In the CDK, there is a Printexc2 module  which allows users to specify
printers for exceptions, that can be used by Printexc.to_string. The
way this is implemented is:

1- when a printer is registered, it has type exn -> string. Such a
printer is:

let not_found_handler exn = match exn with
  Not_found -> "Not Found"
| _ -> raise exn

Thus, it reraises the excepion  if it can not print it.

2- In Printexc.to_string, each printer is tried until a string is
returned. This doesn't require to know about the internal structure of
exceptions. 

- Fabrice

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr