struct

Err(T)

Inherits Result / Struct / Value / Object

Result error .

Constructors

[](exception) : Err

Syntax sugar for Err.fail(exception). exception must be an Exception or a String.

Err["Oops"] # => same as Err.fail("Oops")
Source
conflict(exception) : Err

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
Source
fail(exception) : Err

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
Source
input(exception) : Err

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
Source
new(status : Symbol, exception : T)

Creates a new Err instance with a custom status.

Source
new(exception : T)
Source
not_allowed(exception) : Err

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
Source
not_found(exception) : Err

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
Source
timeout(exception) : Err

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
Source

Class methods

type

Result type as a Symbol.

Err.type # => :err
Source

Instance methods

status

Result status as a Symbol (:done or :fail, etc).

type

Result type as a Symbol.

res.type # => :err
Source
unwrap

Unwrap the result value (like Result::unwrap in Rust). This method raises exception.

Source
value

Returns the result value. Returns a Exception or a String

Source