Browse thread
[Caml-list] exception handling questions
[
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: | Dustin Sallings <dustin@s...> |
| Subject: | Re: [Caml-list] exception handling questions |
On Jan 30, 2004, at 17:02, Eric Stokes wrote:
> What about doing this.
>
> let rec should_process fn =
> try
> (ends_with fn ".") && (is_new_enough fn) && (not (is_gzip fn))
> with x ->
> print_endline("Unknown error determining whether to process "
> ^ fn);
> should_process fn
> ;;
>
> You may need to maintain a bit more state in various places, but it
> could work
> the way you want.
fn is a string, so feeding the same value back in wouldn't help.
The real problem here was a runtime failure in one of the functions
that is very unlikely to occur where this program is actually deployed.
I just wanted to make sure that when a failure did occur, it was dealt
with properly. The ``unknown error'' part was my biggest concern,
because I really didn't have a way to know what went wrong.
The answer to my main concern was the Printexc module:
let should_process fn =
try
(ends_with fn ".") && (is_new_enough fn) && (not (is_gzip fn))
with x ->
print_endline("Unknown error determining whether to process " ^
fn);
print_endline (Printexc.to_string x);
false
--
Dustin Sallings
-------------------
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