Exception: Clickatell::API::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Clickatell::API::Error
- Defined in:
- lib/clickatell/api/error.rb
Overview
Clickatell API Error exception.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Class Method Summary collapse
-
.parse(error_string) ⇒ Object
Creates a new Error from a Clickatell HTTP response string e.g.:.
Instance Method Summary collapse
-
#initialize(code, message) ⇒ Error
constructor
A new instance of Error.
- #to_s ⇒ Object
Constructor Details
#initialize(code, message) ⇒ Error
Returns a new instance of Error.
8 9 10 |
# File 'lib/clickatell/api/error.rb', line 8 def initialize(code, ) @code, @message = code, end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/clickatell/api/error.rb', line 6 def code @code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/clickatell/api/error.rb', line 6 def @message end |
Class Method Details
.parse(error_string) ⇒ Object
Creates a new Error from a Clickatell HTTP response string e.g.:
Error.parse("ERR: 001, Authentication error")
# => #<Clickatell::API::Error code='001' message='Authentication error'>
21 22 23 24 25 |
# File 'lib/clickatell/api/error.rb', line 21 def self.parse(error_string) error_details = error_string.split(':').last.strip code, = error_details.split(',').map { |s| s.strip } self.new(code, ) end |
Instance Method Details
#to_s ⇒ Object
12 13 14 |
# File 'lib/clickatell/api/error.rb', line 12 def to_s "#{@code}: #{@message}" end |