caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Printexc cannot print some (but not all) exceptions
@ 2006-01-13 15:23 Richard Jones
  2006-01-13 15:54 ` [Caml-list] " Virgile Prevosto
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Jones @ 2006-01-13 15:23 UTC (permalink / raw)
  To: caml-list

Hi,

We have an annoying problem that sometimes Printexc seems unable to
print exceptions.  Http_client.Http_error is one such exception that
seems like it can never be printed:

Http_client.Http_error(_)			# from Printexc.to_string
(("Http_client.Http_error"), (2, "foobar"))	# from my dumper
Unix.Unix_error(0, "foobar", "baz")		# from Printexc.to_string
(("Unix.Unix_error"), 0, "foobar", "baz")	# from my dumper
Print.MyException(1, "foobar")			# from Printexc.to_string
(("Print.MyException"), 2, "foobar")		# from my dumper

(The test program which generates this is at the end of the message).

I don't understand what the common factor is which stops exceptions
from being printed, and the code in stdlib/printexc.ml seems fairly
equivalent to my "dumper" code.

Ideas?

Rich.

------------------------------------------------------------- print.ml --
(* ocamlfind ocamlopt -package extlib,netclient -linkpkg print.ml -o print *)

exception MyException of int * string;;

try
  raise (Http_client.Http_error (1, "foobar"))
with exn ->
  prerr_endline (Printexc.to_string exn);;

try
  raise (Http_client.Http_error (2, "foobar"))
with exn ->
  prerr_endline (Std.dump exn);;

try
  raise (Unix.Unix_error (Unix.E2BIG, "foobar", "baz"))
with exn ->
  prerr_endline (Printexc.to_string exn);;

try
  raise (Unix.Unix_error (Unix.E2BIG, "foobar", "baz"))
with exn ->
  prerr_endline (Std.dump exn);;

try
  raise (MyException (1, "foobar"))
with exn ->
  prerr_endline (Printexc.to_string exn);;

try
  raise (MyException (2, "foobar"))
with exn ->
  prerr_endline (Std.dump exn);;


-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-01-13 17:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-13 15:23 Printexc cannot print some (but not all) exceptions Richard Jones
2006-01-13 15:54 ` [Caml-list] " Virgile Prevosto
2006-01-13 16:36   ` Richard Jones
2006-01-13 17:23     ` Virgile Prevosto

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).