Exception: TextMagic::API::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/textmagic/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Error

Creates an instance of TextMagic::API::Error. Error code and error message can be supplied as arguments or in a hash.

TextMagic::API::Error.new(code, message)
TextMagic::API::Error.new("error_code" => code, "error_message" => message)


14
15
16
17
18
19
20
21
# File 'lib/textmagic/error.rb', line 14

def initialize(*args)
  if args.first.is_a?(Hash)
    @code = args.first["error_code"]
    @message = args.first["error_message"]
  else
    @code, @message = args
  end
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



7
8
9
# File 'lib/textmagic/error.rb', line 7

def code
  @code
end

#messageObject (readonly)

Returns the value of attribute message.



7
8
9
# File 'lib/textmagic/error.rb', line 7

def message
  @message
end

Instance Method Details

#to_sObject



23
24
25
# File 'lib/textmagic/error.rb', line 23

def to_s
  "#{@message} (#{@code})"
end