Exception: TextMagic::API::Error
- Inherits:
-
StandardError
- Object
- StandardError
- TextMagic::API::Error
- Defined in:
- lib/error.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Error
constructor
Creates an instance of TextMagic::API::Error.
- #to_s ⇒ Object
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, )
TextMagic::API::Error.new("error_code" => code, "error_message" => )
14 15 16 17 18 19 20 |
# File 'lib/error.rb', line 14 def initialize(*args) if args.first.is_a?(Hash) @code, = args.first["error_code"], args.first["error_message"] else @code, = args end end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
7 8 9 |
# File 'lib/error.rb', line 7 def code @code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/error.rb', line 7 def end |
Instance Method Details
#to_s ⇒ Object
22 23 24 |
# File 'lib/error.rb', line 22 def to_s "#{@message} (#{@code})" end |