Sha256: 8237f60806fbc0e6e6d187bcf5ca6e04aa01c22ef6b686fd1070b3d90612d6d4
Contents?: true
Size: 856 Bytes
Versions: 3
Compression:
Stored size: 856 Bytes
Contents
module TijuanaClient class ValidationError < ::Faraday::Error::ClientError ; end class EmailValidationError < ::Faraday::Error::ClientError ; end class ErrorMiddleware < ::Faraday::Response::RaiseError def on_complete(env) case env[:status] when 400 if env.body.present? response = JSON.parse(env.body) if response['email'] && response['email'].include?('is invalid') raise TijuanaClient::EmailValidationError, response_values(env).to_s else raise TijuanaClient::ValidationError, response_values(env).to_s end else raise TijuanaClient::ValidationError, response_values(env).to_s end when ClientErrorStatuses raise Faraday::Error::ClientError, response_values(env).to_s end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tijuana_client-0.2.4 | lib/tijuana_client/error_middleware.rb |
tijuana_client-0.2.3 | lib/tijuana_client/error_middleware.rb |
tijuana_client-0.2.2 | lib/tijuana_client/error_middleware.rb |