problem
An Error Handling library for Gleam. Inspired by https://github.com/lpil/snag but with your own error type.
Problem gives you:
- An error stack that makes it easier to track the path of an error.
- Use your error type (instead of
String).
gleam add problem
With this library you can add a stack to an error like:
let result = Error("Invalid email")
|> problem.wrap
|> problem.context("when validating email")
|> problem.context("in signup")
Then you can print the stack:
case result {
Error(problem) -> {
problem
|> problem.pretty_print(function.identity)
|> echo
}
_ -> {
todo
}
}
Invalid email
stack:
when validating email
in signup