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 OAA12796; Tue, 21 Jan 2003 14:55:52 +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 OAA14304 for ; Tue, 21 Jan 2003 14:55:51 +0100 (MET) Received: from beaune.inria.fr (beaune.inria.fr [128.93.8.3]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h0LDtpr17120 for ; Tue, 21 Jan 2003 14:55:51 +0100 (MET) Received: by beaune.inria.fr (8.8.8/1.1.22.3/14Sep99-0328PM) id OAA0000013685; Tue, 21 Jan 2003 14:55:50 +0100 (MET) From: Luc Maranget Message-Id: <200301211355.OAA0000013685@beaune.inria.fr> Subject: Re: [Caml-list] String of '_' (any) exception? To: hans@simula.no (Hans Ole Rafaelsen) Date: Tue, 21 Jan 2003 14:55:50 +0100 (MET) Cc: caml-list@inria.fr In-Reply-To: <3azsmvn7xij.fsf@itherther.simula.no> from "Hans Ole Rafaelsen" at jan 21, 2003 08:49:40 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > Hello, > > does it exist a way to get hold of a the string (if any) associated > with an exception, when the exception has been caught with the "_" > (any) exception? What I am interested in is to get hold of the > information which the run-time normally prints when it exits. > > let _ = List.nth [4; 5] 4 > > itherther [14] [08:30] [~] ./a.out > Fatal error: exception Failure("nth") > > I want to get the string produced, or the information needed to > produce it myself. > > The intended usage for this is in a RPC server library, where the > application raise some exception. It would be convenient to re-raise > this as an remote exception, or at least report it back to the client. > > > Kindest regards, Hello, Have a look at the Printexc module As far as I understand your needs, you can write try ... with e -> Printf.printf "Exception: %s\n" (Printexc.to_string e) ; raise e Notice that the << _ >> pattern is changed into a (binding) variable. Cheers, > > Hans Ole Rafaelsen > ------------------- --Luc ------------------- 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