On 04/27/2016 11:36 AM, Daniel Bünzli wrote: > Le mercredi, 27 avril 2016 à 11:22, William a écrit : >> How are we supposed to handle this nicely with the standard library ? Is >> there a better approach to catch those exceptions ? > Capture them immediately around the function call that raises with a _ pattern. > For example: > > match (try Some (List.hd lst) with Failure _ -> None) with > | None -> Printf.printf "empty list\n" > | Some hd -> … > > That's the way these functions should have been defined in the first place. > > Best, > > Daniel > > > Or, with the new pattern matching with exception syntax : match List.hd lst with | exception Failure _ -> Printf.printf "empty list\n" | hd -> ...