Browse thread
Printexc cannot print some (but not all) exceptions
-
Richard Jones
-
Virgile Prevosto
-
Richard Jones
- Virgile Prevosto
-
Richard Jones
-
Virgile Prevosto
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Virgile Prevosto <virgile.prevosto@m...> |
| Subject: | Re: [Caml-list] Printexc cannot print some (but not all) exceptions |
Le ven 13 jan 2006 16:36:29 CET, Richard Jones a écrit: > exception Http_error of (int * string);; > (* The server sent an error message. The left component of the pair is > * the error code, the right component is the error text. > *) > > I'll resort to using Std.dump to find out what's in the exception, > although it would be nice if Printexc could look inside the tuple and > print its contents. > The main issue is that Printexc has no way to know that it is a tuple and not the value of a sum type whose first non-constant constructor takes two arguments. For Std.dump, such a value is a tuple, but it could also have identified it with a list: #require "extlib";; /home/prevosto/softs/godi/lib/ocaml/pkg-lib/extlib: added to search path #load "extlib.cma";; # exception Wrong of (int * int);; exception Wrong of (int * int) # Std.dump (Wrong (1,0));; - : string = "[(\"Wrong\"); 1]" I think that for a function of the standard library it is safer to make a more conservative choice. -- E tutto per oggi, a la prossima volta Virgile