Skip to main content
Version: 0.51.0

How to catch an error thrown in a view ?

Error thrown by calling failwith cannot be caught, the call is compiled to Michelson's FAILWITH instruction.

Therefore, if the error does not need to carry information, you can simply use the type option where 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:


type result<s,f> = ["Ok", s] | ["Error", f]