Version française
Home     About     Download     Resources     Contact us    
Browse thread
Printexc cannot print some (but not all) exceptions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Printexc cannot print some (but not all) exceptions
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