Error thrown by calling
failwith cannot be caught, the call is compiled to Michelson's
Therefore, if the error does not need to carry information, you can simply use the type
None means that an error occurred.
If you need more information on the kind of error, you can either add variants to the correct values if their type is a sum type,
or define your own type result like in OCaml:
In JsLIGO :