Exception: SpookAndPay::MissingValueError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/spook_and_pay/missing_value_error.rb

Overview

A simple error class used to capture situations where the user is attampting to access a value, but it is not available. This is unfortunately necessary due to the way some providers do or do not return certain fields. Rather than allow comparison with nil values we throw this error.

Instance Method Summary collapse

Constructor Details

#initialize(field, record) ⇒ MissingValueError

When instancing this error, it needs to have enough information to point the user to the source.

Parameters:

  • field (String, Symbol)
  • Class

    record



13
14
15
16
# File 'lib/spook_and_pay/missing_value_error.rb', line 13

def initialize(field, record)
  @field = field
  @record = record
end

Instance Method Details

#to_sObject

Human readable error message.

Returns:

  • String



21
22
23
# File 'lib/spook_and_pay/missing_value_error.rb', line 21

def to_s
  "The field #{@field} is missing for #{@record.class}"
end