Class: ZendeskAPI::Middleware::Response::RaiseError
- Inherits:
-
Faraday::Response::RaiseError
- Object
- Faraday::Response::RaiseError
- ZendeskAPI::Middleware::Response::RaiseError
- Defined in:
- lib/zendesk_api/middleware/response/raise_error.rb
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 |
# File 'lib/zendesk_api/middleware/response/raise_error.rb', line 8 def call(env) super rescue Faraday::Error::TimeoutError, Faraday::Error::ConnectionFailed => e raise Error::NetworkError.new(e, env) end |
#on_complete(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/zendesk_api/middleware/response/raise_error.rb', line 14 def on_complete(env) case env[:status] when 404 raise Error::RecordNotFound.new(env) when 422, 413 raise Error::RecordInvalid.new(env) when 100..199, 400..599, 300..303, 305..399 raise Error::NetworkError.new(env) end end |