Personally, I often use the monadic Result type together with a polymorphic variant for the actual errors. This makes dealing with errors from different “levels” of my software (library, command-line tool, and GUI) quite comfortable (and type-safe!).
@keleshev has written a nice blog post on this: Composable Error Handling in OCaml with a recent follow up: Advanced Error Handling in OCaml
10 Likes