Matching on exceptions means you are giving up the help of the compiler to do exhaustiveness check. In the first one, if you don’t add
| None -> clause, the compiler will complain that your match clauses are not exhaustive. AFAIK the second one will not if you missed the
| exception Not_found -> clause.
I will not speak for conventional standards, since I’m not sure whether there’s any, but in general I think it is desirable to strive for using
option in this case.
In a more general case, for modeling an operation that may fail, it’s better to use
result instead of
option, and only use
option if the data strictly either exists or does not exist.
What’s more, using monads will make it easier to chain operations later on (via