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 XAA31496; Mon, 15 Apr 2002 23:30:04 +0200 (MET DST) 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 XAA28429 for ; Mon, 15 Apr 2002 23:30:03 +0200 (MET DST) Received: from hirsch.in-berlin.de (hirsch.in-berlin.de [192.109.42.6]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g3FLU2D24883 for ; Mon, 15 Apr 2002 23:30:03 +0200 (MET DST) Received: from hirsch.in-berlin.de (localhost [127.0.0.1]) by hirsch.in-berlin.de (8.12.1/8.12.1/Debian -2) with ESMTP id g3FLU2nQ014630 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT) for ; Mon, 15 Apr 2002 23:30:02 +0200 Received: (from uucp@localhost) by hirsch.in-berlin.de (8.12.1/8.12.1/Debian -2) with UUCP id g3FLU170014619 for caml-list@inria.fr; Mon, 15 Apr 2002 23:30:01 +0200 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: caml-list@inria.fr Received: from localhost (oliver@localhost) by first.in-berlin.de (8.7.6/8.7.3) with SMTP id WAA00532 for ; Mon, 15 Apr 2002 22:51:43 +0200 Date: Mon, 15 Apr 2002 22:51:41 +0200 (MET DST) From: Oliver Bandel To: caml-list@inria.fr Subject: [Caml-list] Catching errors (Unix-Module) Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, I'm experimtnzing with the Unix-module and try to cath Unix-errors. Look here: ============================================= oliver@first:/home/oliver > unix-top Objective Caml version 3.01 # Unix.stat "/foo/bar";; Uncaught exception: Unix.Unix_error (Unix.ENOENT, "stat", "/foo/bar"). # ============================================= How to handle such Errors? I tried this one: ============================================= # try Unix.stat "/foo/bar" with Unix.Unix_error -> "shi...";; Characters 30-45: The constructor Unix.Unix_error expects 3 argument(s), but is here applied to 0 argument(s) # ============================================= I looked into the reference-Handbook and found that the unix-error is of type error * string * string So, when i look into the line "Uncaught exception: Unix.Unix_error (Unix.ENOENT, "stat", "/foo/bar")." the part "(Unix.ENOENT, "stat", "/foo/bar")" looks like the error*string*string. But how to handle this? What actions can I use here? I may want to ignore some of those errors under some conditions, but I also may want to handle them. What about the type of the error? I understand how normal functions have to be designed in respect to their types. But I don't understand, how exceptions will be handled in respect of their types. Some days ago I tried some simple examples and thought that I had understand the exception-system of OCaml, but now, when doing "real word"-programming, I realize that I didn't understand it. So, please help. TIA, Oliver P.S.: When defining an exception that already exists (Division_by_zero for example), the exception can't be catched with try (at least this problem occured with OCaml 3-.01 on Linux). ------------------- 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