Handling multiple exception types in OCaml

error-handling, ocaml, syntax

Solution

The `with` part is a series of patterns, so you can write this as follows:

try
    (* dangerous code area *)
with
    | Not_found -> (* Not found handling code *)
    | t -> (* Handle other issues here *)

Problem

Is the following possible? ``` try (* danger zone *) with Not_found e -> (* code to handle not found *) with t -> (* code to handle all other issues *) ``` If I type that into the toplevel, I get a syntax error on the second `with`. Perhaps there's some syntax I'm not aware of? Is the preferred method to prepend another `try` to match each `with`?

Original source