Class: Cuprum::Errors::OperationNotCalled

Inherits:
Cuprum::Error show all
Defined in:
lib/cuprum/errors/operation_not_called.rb

Overview

Error class to be used when trying to access the result of an uncalled Operation.

Constant Summary collapse

MESSAGE_FORMAT =

Format for generating error message.

'%s was not called and does not have a result'

Instance Attribute Summary collapse

Attributes inherited from Cuprum::Error

#message

Instance Method Summary collapse

Methods inherited from Cuprum::Error

#==

Constructor Details

#initialize(operation:) ⇒ OperationNotCalled

Returns a new instance of OperationNotCalled.

Parameters:



17
18
19
20
21
22
23
24
# File 'lib/cuprum/errors/operation_not_called.rb', line 17

def initialize(operation:)
  @operation = operation

  class_name = operation&.class&.name || 'operation'
  message    = MESSAGE_FORMAT % class_name

  super(message: message)
end

Instance Attribute Details

#operationCuprum::Operation (readonly)

Returns The uncalled operation.

Returns:



27
28
29
# File 'lib/cuprum/errors/operation_not_called.rb', line 27

def operation
  @operation
end