[
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: | skaller <skaller@u...> |
| Subject: | Re: [Caml-list] try with |
On Sun, 2007-08-05 at 17:29 +0200, tmp123@menta.net wrote: > Hello, > > Sorry for an easy question about exceptions: > > If in a code like: > > let v1 = f1 () in > f2 v1 > > I like to handle in a different way an exception (like Not_found) > produced inside f1 of the same one produced in f2 (or even not treat the > one produced in f2), which one is a correct way to write the code? Eliminate the exceptions, they're usually a bad idea: let v1 = try Some (f1 ()) with Not_found -> None in let v2 = match v1 with | None -> Error1 | Some x -> try Some (f2 x) with Not_found -> None in match v2 with | None -> Error2 | Some v2 -> ... -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net