Exception: MonadOxide::OptionReturnExpectedError

Inherits:
MonadOxideError
  • Object
show all
Defined in:
lib/option.rb

Overview

This ‘Exception’ is produced when a method that expects the function or block to provide a ‘Result’ but was given something else. Generally this Exception is not raised, but instead converts the Result into a an Err. Example methods with this behavior are Result#and_then and Result#or_else.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ OptionReturnExpectedError

The transformation expected a ‘Result’ but got something else.

Parameters:

  • data (Object)

    Whatever we got that wasn’t a ‘Result’.



29
30
31
32
# File 'lib/option.rb', line 29

def initialize(data)
  super("A Result was expected but got #{data.inspect}.")
  data = @data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



33
34
35
# File 'lib/option.rb', line 33

def data
  @data
end