Method: Clickatell::API::Error.parse

Defined in:
lib/clickatell/api/error.rb

.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'>


17
18
19
20
21
# File 'lib/clickatell/api/error.rb', line 17

def self.parse(error_string)
  error_details = error_string.split(':').last.strip
  code, message = error_details.split(',').map { |s| s.strip }
  self.new(code, message)
end