Class: Dry::Monads::Try::Error
- Inherits:
-
Dry::Monads::Try
- Object
- Dry::Monads::Try
- Dry::Monads::Try::Error
- Includes:
- RightBiased::Left
- Defined in:
- lib/dry/monads/try.rb,
lib/dry/monads/maybe.rb,
lib/dry/monads/either.rb,
lib/dry/monads/result.rb
Overview
Represents a result of a failed execution.
Constant Summary
Constants inherited from Dry::Monads::Try
Instance Attribute Summary
Attributes inherited from Dry::Monads::Try
Instance Method Summary collapse
- #===(other) ⇒ Boolean
-
#initialize(exception) ⇒ Error
constructor
A new instance of Error.
-
#or(*args) ⇒ Object
If a block is given passes internal value to it and returns the result, otherwise simply returns the first argument.
- #to_maybe ⇒ Maybe::None
- #to_result ⇒ Result::Failure
- #to_s ⇒ String (also: #inspect)
Methods included from RightBiased::Left
#and, #apply, #bind, #deconstruct, #deconstruct_keys, #discard, #flatten, #fmap, #or_fmap, #tee, trace_caller, #value!, #value_or
Methods inherited from Dry::Monads::Try
[], #error?, pure, run, #to_monad, #value?
Constructor Details
#initialize(exception) ⇒ Error
Returns a new instance of Error.
181 182 183 |
# File 'lib/dry/monads/try.rb', line 181 def initialize(exception) @exception = exception end |
Instance Method Details
#===(other) ⇒ Boolean
211 212 213 |
# File 'lib/dry/monads/try.rb', line 211 def ===(other) Error === other && exception === other.exception end |
#or(*args) ⇒ Object
If a block is given passes internal value to it and returns the result, otherwise simply returns the first argument.
201 202 203 204 205 206 207 |
# File 'lib/dry/monads/try.rb', line 201 def or(*args) if block_given? yield(exception, *args) else args[0] end end |
#to_maybe ⇒ Maybe::None
366 367 368 |
# File 'lib/dry/monads/maybe.rb', line 366 def to_maybe Maybe::None.new(RightBiased::Left.trace_caller) end |
#to_result ⇒ Result::Failure
434 435 436 |
# File 'lib/dry/monads/result.rb', line 434 def to_result Result::Failure.new(exception, RightBiased::Left.trace_caller) end |
#to_s ⇒ String Also known as: inspect
186 187 188 |
# File 'lib/dry/monads/try.rb', line 186 def to_s "Try::Error(#{exception.class}: #{exception.})" end |