caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Catching errors (Unix-Module)
@ 2002-04-15 20:51 Oliver Bandel
  2002-04-15 22:59 ` Shawn Wagner
  0 siblings, 1 reply; 5+ messages in thread
From: Oliver Bandel @ 2002-04-15 20:51 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-04-16 13:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-15 20:51 [Caml-list] Catching errors (Unix-Module) Oliver Bandel
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).