class Gistance::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 [Gistance::Error]
# File lib/gistance/error.rb, line 10 def self.from_response(response) status = ::MultiJson.load(response[:body])['status'] case status when 'INVALID_REQUEST' raise Gistance::InvalidRequest, status when 'MAX_ELEMENTS_EXCEEDED' raise Gistance::MaxElementsExceeded, status when 'OVER_QUERY_LIMIT' raise Gistance::OverQueryLimit, status when 'REQUEST_DENIED' raise Gistance::RequestDenied, status when 'UNKNOWN_ERROR' raise Gistance::UnknownError, status when 'NOT_FOUND' raise Gistance::NotFound, status when 'ZERO_RESULTS' raise Gistance::ZeroResults, status end end