Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
To: caml-list@inria.fr
Subject: Printexc cannot print some (but not all) exceptions
Date: Fri, 13 Jan 2006 15:23:34 +0000	[thread overview]
Message-ID: <20060113152333.GA14618@furbychan.cocan.org> (raw)

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


             reply	other threads:[~2006-01-13 14:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-13 15:23 Richard Jones [this message]
2006-01-13 15:54 ` [Caml-list] " Virgile Prevosto
2006-01-13 16:36   ` Richard Jones
2006-01-13 17:23     ` Virgile Prevosto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060113152333.GA14618@furbychan.cocan.org \
    --to=rich@annexia.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox