8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/tijuana_client/error_middleware.rb', line 8
def on_complete(env)
case env[:status]
when 400
if env.body.present?
response = JSON.parse(env.body)
if 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 400..600
raise Faraday::ClientError, response_values(env).to_s
end
end
|