Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Change Response::RaiseError to be processed last #6

Closed
wants to merge 1 commit into from

2 participants

@vandrijevik

Since response middleware are processed in the reverse order of being added, this makes Response::RaiseError be last, so the Exceptions raised have nicer, parsed bodies.

@stve

This could create a problem though since not all bodies are formatted in a way that would allow them to be parsed.

@vandrijevik

I’m not sure how this is a problem - the response handlers will only attempt to parse responses with the appropriate content type, so if a response body doesn’t match JSON, XML or HTML it will not be parsed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 1, 2011
  1. @vandrijevik
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/faraday_stack.rb
View
2  lib/faraday_stack.rb
@@ -40,12 +40,12 @@ def self.build(url = nil, options = {})
builder.request :url_encoded
builder.request :json
yield builder if block_given?
+ builder.response :raise_error
builder.use ResponseXML, :content_type => /[+\/]xml$/
builder.use ResponseHTML, :content_type => 'text/html'
builder.use ResponseJSON, :content_type => /(application|text)\/json/
builder.use ResponseJSON::MimeTypeFix, :content_type => /text\/(plain|javascript)/
builder.use FollowRedirects
- builder.response :raise_error
builder.adapter Faraday.default_adapter
end
end
Something went wrong with that request. Please try again.