Sha256: b706a4050ccd6e33941b860ff472719852be69b238adbc9e1bde1d60d1b1fd50
Contents?: true
Size: 1.83 KB
Versions: 2
Compression:
Stored size: 1.83 KB
Contents
module Quaderno module Exceptions class InvalidSubdomainOrToken < Exception end class InvalidID < Exception end class RateLimitExceeded < Exception end class HasAssociatedDocuments < Exception end class RequiredFieldsEmptyOrInvalid < Exception end class ThrottleLimitExceeded < Exception end def self.included(receiver) receiver.send :extend, ClassMethods end module ClassMethods def check_exception_for(party_response, params = {}) if params[:throttle_limit].nil? == false raise(Quaderno::Exceptions::ThrottleLimitExceeded, 'Throttle limit exceeded, please try again later') if party_response.response.class == Net::HTTPServiceUnavailable end if params[:rate_limit].nil? == false raise(Quaderno::Exceptions::RateLimitExceeded, 'Rate limit exceeded') if party_response.response.class == Net::HTTPForbidden end if params[:subdomain_or_token].nil? == false raise(Quaderno::Exceptions::InvalidSubdomainOrToken, 'Invalid subdomain or token') if party_response.response.class == Net::HTTPUnauthorized end if params[:id].nil? == false raise(Quaderno::Exceptions::InvalidID, "Invalid #{ api_model } instance identifier") if (party_response.response.class == Net::HTTPInternalServerError) || (party_response.response.class == Net::HTTPNotFound) end if params[:required_fields].nil? == false raise(Quaderno::Exceptions::RequiredFieldsEmptyOrInvalid, party_response.body) if party_response.response.class == Net::HTTPUnprocessableEntity end if params[:has_documents].nil? == false raise(Quaderno::Exceptions::HasAssociatedDocuments, party_response.body) if party_response.response.class == Net::HTTPClientError end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
quaderno-1.8.0 | lib/quaderno-ruby/exceptions/exceptions.rb |
quaderno-1.7.3 | lib/quaderno-ruby/exceptions/exceptions.rb |