Class: Klaviyo::Errors::RequestError
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Klaviyo::Errors::RequestError
- Defined in:
- lib/klaviyo/errors.rb
Instance Method Summary collapse
Instance Method Details
#on_complete(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/klaviyo/errors.rb', line 12 def on_complete(env) # Ignore any non-error response codes return if (status = env[:status]) < 400 case status when 404 raise Errors::NotFound, env[:body] when 422 raise Errors::UnprocessableEntity, env[:body] when 401 raise Errors::NotAuthorized, env[:body] when 407 # mimic the behavior that we get with proxy requests with HTTPS raise Faraday::Error::ConnectionFailed, %{407 "Proxy Authentication Required "} else raise Errors::InternalServerError, env[:body] # Treat any other errors as 500 end end |