outcome/problem
Types
A list of context entries
pub type ContextStack =
List(String)
The error type ie. Result(t, Problem)
This contains the error, the severity and the context stack.
pub type Problem(err) {
Problem(error: err, severity: Severity, stack: ContextStack)
}
Constructors
-
Problem(error: err, severity: Severity, stack: ContextStack)
Functions
pub fn get_failure(problem: Problem(a), default_value: a) -> a
Use this to show a failure to a user.
Extracts the Error value from a Problem
when the severity is Failure
.
otherwise it will return the default value given.
Example
case result {
Ok(value) -> io.debug("Success")
Error(problem) -> io.error(problem.get_failure(problem, "Something went wrong"))
}
pub fn new_defect(error: a) -> Problem(a)
Create a Defect
Use this if you need the Problem
type only.
Usually you will use as_defect
instead.
Example
problem.new_defect("Something went wrong")
pub fn new_failure(error: a) -> Problem(a)
Create a Failure
Use this if you need the Problem
type only.
Usually you will use result_to_failure
instead.
Example
problem.new_failure("Something went wrong")