From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@inria.fr
Subject: [Caml-list] Catching errors (Unix-Module)
Date: Mon, 15 Apr 2002 22:51:41 +0200 (MET DST) [thread overview]
Message-ID: <Pine.LNX.3.95.1020415223458.408A-100000@first.in-berlin.de> (raw)
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
next reply other threads:[~2002-04-15 21:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-15 20:51 Oliver Bandel [this message]
2002-04-15 22:59 ` Shawn Wagner
2002-04-16 13:04 ` Oliver Bandel
2002-04-16 13:22 ` Remi VANICAT
2002-04-16 13:56 ` Hendrik Tews
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=Pine.LNX.3.95.1020415223458.408A-100000@first.in-berlin.de \
--to=oliver@first.in-berlin.de \
--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