class Azimuth::Error
Custom error class
Public Class Methods
from_response(response)
click to toggle source
Returns the Error
based on status and response message.
@param [Hash] response HTTP response @return [Azimuth::Error]
# File lib/azimuth/error.rb, line 10 def self.from_response(response) parsed_response_info = ::MultiJson.load(response[:body])['info'] status_code = parsed_response_info['statuscode'] return if status_code == 0 if error_message = parsed_response_info['messages'] error_message = error_message.join(' ') end case status_code when 400 raise Azimuth::ErrorWithInput, error_message when 403 raise Azimuth::KeyRelatedError, error_message when 500 raise Azimuth::UnknownError, error_message when 600...699 raise Azimuth::OtherError, error_message end end