I have a OCaml projet, which is later converted to JavaScript by js_of_ocaml. I wrap some functions like follows:
Js.Unsafe.global##.parseFile := Js.wrap_callback
(fun s -> Js.string (E.parse_file (Js.to_string s)));
Then, in JavaScript, I could call parseFile("abc").
In the OCaml code, for example, E.parse_file may raise exceptions by failwith "this is why". I would like to know how to catch this exception in JavaScript code, and eventually catch this is why?
try {
parseFile("abc")
}
catch(error) {
???
}