struct Err(T)
Overview
Result
error .
Defined in:
result.crConstructors
-
.[](exception) : Err
Syntax sugar for
Err.fail(exception)
. -
.conflict(exception) : Err
Creates a new
Err
instance with the status:conflict
. -
.fail(exception) : Err
Creates a new
Err
instance with the status:fail
. -
.input(exception) : Err
Creates a new
Err
instance with the status:input
. - .new(status : Symbol, exception : T)
- .new(exception : T)
-
.not_allowed(exception) : Err
Creates a new
Err
instance with the status:not_allowed
. -
.not_found(exception) : Err
Creates a new
Err
instance with the status:not_found
. -
.timeout(exception) : Err
Creates a new
Err
instance with the status:timeout
.
Class Method Summary
-
.type : Symbol
Result
type as aSymbol
.
Instance Method Summary
-
#status : Symbol
Result
status as aSymbol
(:done or :fail, etc). -
#type : Symbol
Result
type as aSymbol
. -
#unwrap
Unwrap the result
#value
(like Result::unwrap in Rust). -
#value : T
Returns the result value.
Instance methods inherited from struct Result(T)
err? : Bool
err?,
ok? : Bool
ok?,
state : Tuple(Symbol, Symbol, T)
state,
status : Symbol
status,
status?(s : Symbol) : Bool
status?,
type : Symbol
type,
unwrap
unwrap,
value : T
value
Constructor methods inherited from struct Result(T)
new
new
Class methods inherited from struct Result(T)
err? : Bool
err?,
ok? : Bool
ok?
Constructor Detail
Syntax sugar for Err.fail(exception)
.
exception must be an Exception
or a String
.
Err["Oops"] # => same as Err.fail("Oops")
Creates a new Err
instance with the status :conflict
.
This method is a shortcut for Err.new :conflict, exception
.
res = Err.conflict(exception)
res.status # => :conflict
# Raise
res.unwrap
# Or get the exception value
pp res.value
Creates a new Err
instance with the status :fail
.
This method is a shortcut for Err.new :fail, exception
.
res = Err.fail(exception)
res.status # => :fail
# Raise
res.unwrap
# Or get the exception value
pp res.value
Creates a new Err
instance with the status :input
.
This method is a shortcut for Err.new :input, exception
.
res = Err.input(exception)
res.status # => :input
# Raise
res.unwrap
# Or get the exception value
pp res.value
Creates a new Err
instance with the status :not_allowed
.
This method is a shortcut for Err.new :not_allowed, exception
.
res = Err.not_allowed(exception)
res.status # => :not_allowed
# Raise
res.unwrap
# Or get the exception value
pp res.value
Creates a new Err
instance with the status :not_found
.
This method is a shortcut for Err.new :not_found, exception
.
res = Err.not_found(exception)
res.status # => :not_found
# Raise
res.unwrap
# Or get the exception value
pp res.value
Creates a new Err
instance with the status :timeout
.
This method is a shortcut for Err.new :timeout, exception
.
res = Err.timeout(exception)
res.status # => :timeout
# Raise
res.unwrap
# Or get the exception value
pp res.value