From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA10041; Thu, 6 Nov 2003 10:50:36 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA09976 for ; Thu, 6 Nov 2003 10:50:35 +0100 (MET) Received: from bob.west.spy.net (mail.west.spy.net [66.149.231.226]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hA69oY127691 for ; Thu, 6 Nov 2003 10:50:34 +0100 (MET) Received: from [192.168.1.196] (dhcp-196.west.spy.net [192.168.1.196]) by bob.west.spy.net (Postfix) with ESMTP id 0745358DB; Thu, 6 Nov 2003 01:50:30 -0800 (PST) In-Reply-To: <20031106090201.GA9550@redhat.com> References: <979ADAF0-1034-11D8-ADB5-000393CFE6B8@spy.net> <20031106090201.GA9550@redhat.com> Mime-Version: 1.0 (Apple Message framework v606) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: Caml Mailing List From: Dustin Sallings Subject: Re: [Caml-list] exception handling questions Date: Thu, 6 Nov 2003 01:50:30 -0800 To: Richard Jones X-Mailer: Apple Mail (2.606) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 ocamlrun:01 endline:01 passwd:01 passwd:01 abort:01 toplevel:01 nov:01 stacks:02 exception:02 exception:02 uncaught:02 stack:02 stack:02 similarly:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Nov 6, 2003, at 1:02, Richard Jones wrote: >> One thing that really seems to be missing from exception handling is >> the ability to print a stack trace from an exception. I realize >> there's a flag on the ocamlrun to print stacks for uncaught >> exceptions, >> but that's not exactly what I'm looking for. I'd like to be able to >> catch and exception, log it, and continue. >> >> Similarly, is there a way to print an exception at least like the >> toplevel does? I can catch any type of exception with the appropriate >> pattern, but I don't see how I can report it without expecting it. > > And while we're at it, printing out a full stack trace with function > names and parameters. Yes, that would be nice, but I'm trying to not ask for too much. :) As it is, I've got a function that can fail when processing large amounts of data and it's OK to lose one as long as I know why. Right now, the only way to know why is to rethrow: let should_process fn = try (ends_with fn ".") && (is_new_enough fn) && (not (is_gzip fn)) with x -> print_endline("Unknown error determining whether to process " ^ fn); raise x ;; Example output: Unknown error determining whether to process /tmp/x/passwd. Fatal error: exception Sys_error("/tmp/x/passwd.: Permission denied") I'd be plenty happy to print out that message and continue, but in the meantime, I've gotta have it abort. -- Dustin Sallings ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners