Skip to content

Commit

Permalink
Doc: Added raise_error middleware configuration (#1412)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicosvirjt committed Apr 27, 2022
1 parent 24b3fd3 commit 24eafaa
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/middleware/response/raise_error.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ response returns with a 4xx or 5xx status code. All exceptions are initialized
providing the response `status`, `headers`, and `body`.

```ruby
conn = Faraday.new(url: 'http://httpbingo.org') do |faraday|
faraday.response :raise_error # raise Faraday::Error on status code 4xx or 5xx
end

begin
conn.get('/wrong-url') # => Assume this raises a 404 response
rescue Faraday::ResourceNotFound => e
Expand Down

0 comments on commit 24eafaa

Please sign in to comment.