Class: SMSApi::Response::Error

Inherits:
SMSApi::Response show all
Defined in:
lib/client_smsapi/response/error.rb

Constant Summary collapse

MESSAGES =
YAML.load_file('lib/client_smsapi/error/messages.yml')['error'].freeze

Constants inherited from SMSApi::Response

ALLOWED_STATUSES, InvalidStatus

Instance Attribute Summary collapse

Attributes inherited from SMSApi::Response

#status

Instance Method Summary collapse

Constructor Details

#initialize(code = nil) ⇒ Error

Returns a new instance of Error.



8
9
10
11
12
13
# File 'lib/client_smsapi/response/error.rb', line 8

def initialize(code = nil)
  @code      = code
  @message   = MESSAGES.fetch(code, 'Unknown error')

  super(:error)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/client_smsapi/response/error.rb', line 6

def code
  @code
end

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'lib/client_smsapi/response/error.rb', line 6

def message
  @message
end

Instance Method Details

#exceptionObject



15
16
17
# File 'lib/client_smsapi/response/error.rb', line 15

def exception
  StandardError.new("[CODE: #{code}] #{message}")
end