faraday 2.7.11 → 2.7.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/faraday/error.rb +4 -0
- data/lib/faraday/response/raise_error.rb +2 -0
- data/lib/faraday/version.rb +1 -1
- data/spec/faraday/response/raise_error_spec.rb +12 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 975b437b7cfe03559c0c2affea747fb2bc10c8439d1f05c8f901261ebf8ff956
|
4
|
+
data.tar.gz: aa20a42dc8dbd47d970e28000cbf693e39c80a3806d6b3f5348759858e7d4812
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31eaeb27af10b33774afbb9c83d46a2c310dd422602345c94d198737a1f1ff95692aa48235e47082177b15f540caaa4c3733bd739b17375da71f02851913e353
|
7
|
+
data.tar.gz: 6d610f6e22f77447b0eaef8ab5c5cd424e119a1db1f654affd1eb1dd9f6064ba53f837ba0e36130a2454826656f7113aba54af0c393ac9dae6f255468ae007ac
|
data/lib/faraday/error.rb
CHANGED
@@ -124,6 +124,10 @@ module Faraday
|
|
124
124
|
class UnprocessableEntityError < ClientError
|
125
125
|
end
|
126
126
|
|
127
|
+
# Raised by Faraday::Response::RaiseError in case of a 429 response.
|
128
|
+
class TooManyRequestsError < ClientError
|
129
|
+
end
|
130
|
+
|
127
131
|
# Faraday server error class. Represents 5xx status responses.
|
128
132
|
class ServerError < Error
|
129
133
|
end
|
@@ -30,6 +30,8 @@ module Faraday
|
|
30
30
|
raise Faraday::ConflictError, response_values(env)
|
31
31
|
when 422
|
32
32
|
raise Faraday::UnprocessableEntityError, response_values(env)
|
33
|
+
when 429
|
34
|
+
raise Faraday::TooManyRequestsError, response_values(env)
|
33
35
|
when ClientErrorStatuses
|
34
36
|
raise Faraday::ClientError, response_values(env)
|
35
37
|
when ServerErrorStatuses
|
data/lib/faraday/version.rb
CHANGED
@@ -14,6 +14,7 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
14
14
|
stub.get('request-timeout') { [408, { 'X-Reason' => 'because' }, 'keep looking'] }
|
15
15
|
stub.get('conflict') { [409, { 'X-Reason' => 'because' }, 'keep looking'] }
|
16
16
|
stub.get('unprocessable-entity') { [422, { 'X-Reason' => 'because' }, 'keep looking'] }
|
17
|
+
stub.get('too-many-requests') { [429, { 'X-Reason' => 'because' }, 'keep looking'] }
|
17
18
|
stub.get('4xx') { [499, { 'X-Reason' => 'because' }, 'keep looking'] }
|
18
19
|
stub.get('nil-status') { [nil, { 'X-Reason' => 'nil' }, 'fail'] }
|
19
20
|
stub.get('server-error') { [500, { 'X-Error' => 'bailout' }, 'fail'] }
|
@@ -113,6 +114,17 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
113
114
|
end
|
114
115
|
end
|
115
116
|
|
117
|
+
it 'raises Faraday::TooManyRequestsError for 429 responses' do
|
118
|
+
expect { conn.get('too-many-requests') }.to raise_error(Faraday::TooManyRequestsError) do |ex|
|
119
|
+
expect(ex.message).to eq('the server responded with status 429')
|
120
|
+
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
121
|
+
expect(ex.response[:status]).to eq(429)
|
122
|
+
expect(ex.response_status).to eq(429)
|
123
|
+
expect(ex.response_body).to eq('keep looking')
|
124
|
+
expect(ex.response_headers['X-Reason']).to eq('because')
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
116
128
|
it 'raises Faraday::NilStatusError for nil status in response' do
|
117
129
|
expect { conn.get('nil-status') }.to raise_error(Faraday::NilStatusError) do |ex|
|
118
130
|
expect(ex.message).to eq('http status could not be derived from the server response')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "@technoweenie"
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-11-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: base64
|
@@ -145,7 +145,7 @@ licenses:
|
|
145
145
|
- MIT
|
146
146
|
metadata:
|
147
147
|
homepage_uri: https://lostisland.github.io/faraday
|
148
|
-
changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.7.
|
148
|
+
changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.7.12
|
149
149
|
source_code_uri: https://github.com/lostisland/faraday
|
150
150
|
bug_tracker_uri: https://github.com/lostisland/faraday/issues
|
151
151
|
post_install_message:
|