Class: LunchMoney::Errors

Inherits:
Object
  • Object
show all
Defined in:
lib/lunchmoney/errors.rb

Overview

This class is used to represent errors returned directly from the LunchMoney API. This class has been set up to act like an array, delegating a lot of common array getter methods directly to messages for you.

Examples:

api = LunchMoney::Api.new
response = api.categories

response.class
=> LunchMoney::Errors

response.first
=> "Some error returned by the API"

response.empty?
=> false

response[0]
=> "Some error returned by the API"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message: nil) ⇒ void

Parameters:

  • message (String, nil) (defaults to: nil)


27
28
29
30
31
# File 'lib/lunchmoney/errors.rb', line 27

def initialize(message: nil)
  @messages = T.let([], T::Array[String])

  @messages << message unless message.nil?
end

Instance Attribute Details

#messagesArray<String>

Returns:

  • (Array<String>)


24
25
26
# File 'lib/lunchmoney/errors.rb', line 24

def messages
  @messages
end