outcome
Types
The error type ie. Result(t, Problem)
An application error is either a Defect or a Failure.
A Defect is an unexpected application error, which shouldn’t be shown to the user.
A Failure is an expected error.
pub type Problem {
Defect(message: String, stack: Stack)
Failure(message: String, stack: Stack)
}
Constructors
-
Defect(message: String, stack: Stack)
-
Failure(message: String, stack: Stack)
Stax entries Context is just information about the place in the application to build a stack trace.
pub type StackEntry {
StackEntryContext(String)
StackEntryDefect(String)
StackEntryFailure(String)
}
Constructors
-
StackEntryContext(String)
-
StackEntryDefect(String)
-
StackEntryFailure(String)
Functions
pub fn add_context_to_problem(
problem: Problem,
value: String,
) -> Problem
A context to a Problem
pub fn add_defect_to_problem_stack(
problem: Problem,
failure: String,
) -> Problem
pub fn add_failure_to_problem_stack(
problem: Problem,
failure: String,
) -> Problem
pub fn add_to_problem_stack(
problem: Problem,
stack_entry: StackEntry,
) -> Problem
Add an StackEntry to the top of a Problem stack
pub fn as_defect(
result: Result(a, Nil),
e: String,
) -> Result(a, Problem)
Replaces an Error(Nil)
with an Error(Defect)
pub fn as_failure(
result: Result(a, Nil),
e: String,
) -> Result(a, Problem)
Replaces an Error(Nil) with an Error(Failure)
pub fn error_with_defect(defect: String) -> Result(a, Problem)
Create a Defect wrapped in an Error
pub fn error_with_failure(failure: String) -> Result(a, Problem)
Create Failure wrapped in an Error
pub fn into_defect(
result: Result(a, String),
) -> Result(a, Problem)
Convert an Error(String)
into an Error(Defect)
pub fn into_failure(
result: Result(a, String),
) -> Result(a, Problem)
Convert an Error(String)
into an Error(Failure)
pub fn map_into_defect(
result: Result(a, b),
mapper: fn(b) -> String,
) -> Result(a, Problem)
Convert an Error(t)
into a wrapped Defect, by using a mapping function
pub fn new_defect(message: String) -> Problem
pub fn new_failure(message: String) -> Problem
pub fn pretty_print(problem: Problem) -> String
pub fn problem_with_defect(
problem: Problem,
defect_message: String,
) -> Problem
pub fn problem_with_failure(
problem: Problem,
failure_message: String,
) -> Problem
pub fn unwrap_failure(
problem: Problem,
default_message: String,
) -> String
pub fn with_context(
outcome outcome: Result(a, Problem),
context context: String,
) -> Result(a, Problem)
Add context to an Outcome
pub fn with_defect(
outcome outcome: Result(a, Problem),
defect_message defect_message: String,
) -> Result(a, Problem)
pub fn with_failure(
outcome outcome: Result(a, Problem),
failure_message failure_message: String,
) -> Result(a, Problem)