Browse thread
[Caml-list] Catching errors (Unix-Module)
- Oliver Bandel
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Oliver Bandel <oliver@f...> |
| Subject: | [Caml-list] Catching errors (Unix-Module) |
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