Class: XeroKiwi::Client::ResponseHandler

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/xero_kiwi/client.rb

Overview

Faraday middleware that maps non-2xx responses onto our exception hierarchy. Lives outside the retry middleware so it only fires on the final response.

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



667
668
669
670
671
672
673
674
# File 'lib/xero_kiwi/client.rb', line 667

def on_complete(env)
  # 304 Not Modified is a valid response to a conditional GET
  # (If-Modified-Since). Let it through so the list helper can
  # return an empty Page.
  return if (200..299).cover?(env.status) || env.status == 304

  raise error_for(env)
end