This signature describes an Error
module that has some control over unexpected exceptions.
If you want to handle unexpected exceptions as they appear, you should probably define an error case with the type exn
, like in the code below:
module Error = struct
type t =
| Because_reasons
| Unexpected of exn
let panic e = Unexpected e
end
include Error
This type describes the errors of your project. It's one of the main requirements to create a result monad.
If you don't want to specify your errors upfront, you can still use something like unit
or string
as error type.
When an exception is detected, this module can either terminate the process with a proper message or chose convert the error to the type t
.