Original code:
# let name_of_binary_digit digit =
try
List.assoc digit [0, "zero"; 1, "one"]
with Not_found ->
"not a binary digit";;
Code adapted to JS/core
let name_of_binary_digit digit =
try List.Assoc.find_exn [ (0, "zero"); (1, "one") ] digit ~equal:( = ) with Not_found -> "not a binary digit"
Error I get:
247 | try List.Assoc.find_exn [ (0, "zero"); (1, "one") ] digit ~equal:( = ) with Not_found -> "not a binary digit"
^^^^^^^^^
Error (alert deprecated): Not_found
[since 2018-02] Instead of raising [Not_found], consider using [raise_s] with an
informative error message. If code needs to distinguish [Not_found] from other
exceptions, please change it to handle both [Not_found] and [Not_found_s]. Then, instead
of raising [Not_found], raise [Not_found_s] with an informative error message.
My confusion:
I am CATCHING, not THROWING an exception at that location. What is going on, and how do I fix this ?