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 PAA10135; Tue, 16 Apr 2002 15:56:49 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA32599 for ; Tue, 16 Apr 2002 15:56:49 +0200 (MET DST) Received: from tcs.inf.tu-dresden.de (tcs.inf.tu-dresden.de [141.76.75.101]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g3GDum516262 for ; Tue, 16 Apr 2002 15:56:48 +0200 (MET DST) Received: from ithif51 (ithif51 [141.76.75.51]) by tcs.inf.tu-dresden.de (8.12.0.Beta7/8.12.0.Beta7) with ESMTP id g3GDulIr010976; Tue, 16 Apr 2002 15:56:47 +0200 (MET DST) Received: from tews by ithif51 with local (Exim 3.12 #1 (Debian)) id 16xTRv-0001Lp-00; Tue, 16 Apr 2002 15:56:47 +0200 From: Hendrik Tews MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15548.11679.501664.154023@gargle.gargle.HOWL> Date: Tue, 16 Apr 2002 15:56:47 +0200 (CEST) To: Oliver Bandel , caml-list@inria.fr Subject: Re: [Caml-list] Catching errors (Unix-Module) In-Reply-To: References: <20020415155915.K32318@speakeasy.org> X-Mailer: VM 6.75 under Emacs 20.7.2 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Oliver Bandel writes: Date: Tue, 16 Apr 2002 15:04:34 +0200 (MET DST) Subject: Re: [Caml-list] Catching errors (Unix-Module) OK, let's try it: [...] This expression has type unit but is here used with type Unix.stats Or is there a general problem with that code? Well, the catch has to return something compatible with Unix.stat. So you can try 1. use optional values try Some (Unix.stat "/foo/bar") with | Unix.Unix_error (code, func, file) -> Printf.fprintf stderr "Couldn't %s '%s': %s!\n" func file (Unix.error_message code); None ;; 2. reraise the exception try Unix.stat "/foo/bar" with | Unix.Unix_error (code, func, file) as exec -> Printf.fprintf stderr "Couldn't %s '%s': %s!\n" func file (Unix.error_message code); raise exec ;; 3. raise another exception exception MyUnixException;; try Unix.stat "/foo/bar" with | Unix.Unix_error (code, func, file) as exec -> Printf.fprintf stderr "Couldn't %s '%s': %s!\n" func file (Unix.error_message code); raise MyUnixException ;; In case you get an error like Reference to undefined global `Unix' you have to built a toplevel containing the unix module: /usr/local/ocaml-3.01/bin/ocamlmktop -o mytop unix.cma Bye, Hendrik ------------------- 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