Exception: MonadOxide::ResultReturnExpectedError

Inherits:
MonadOxideError
  • Object
show all
Defined in:
lib/result.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) ⇒ ResultReturnExpectedError

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

Parameters:

  • data (Object)

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



23
24
25
26
# File 'lib/result.rb', line 23

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.



27
28
29
# File 'lib/result.rb', line 27

def data
  @data
end