restful_resource 2.0.1 → 2.0.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82a879953f0ea77b78d0d10e389f71c52b871478
|
4
|
+
data.tar.gz: 58780ad094d558ac4fcc2a132c3df4405449b252
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a7514ee216cd7f0d65844ce0f2e40f545792b61c0272b5249a089b4cb2c8564a01b83fcedb0df47e197ecd7d228957d615477c482921e42c4936ca0c51bfac1
|
7
|
+
data.tar.gz: 2e71dc51a9751ae363e9aa840f513196d704fcda064133a5ba86eac3fc64fcd7b1ce9abe8c968d46fb0a73e5a53ae78e3f8f8ff15dbc5adec5203e25f1adf6ce
|
@@ -36,6 +36,12 @@ module RestfulResource
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
class BadGateway < RetryableError
|
40
|
+
def message
|
41
|
+
"HTTP 502: Bad gateway"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
39
45
|
class ServiceUnavailable < RetryableError
|
40
46
|
def message
|
41
47
|
"HTTP 503: Service unavailable"
|
@@ -154,6 +160,7 @@ module RestfulResource
|
|
154
160
|
case response[:status]
|
155
161
|
when 404 then raise HttpClient::ResourceNotFound.new(request, response)
|
156
162
|
when 422 then raise HttpClient::UnprocessableEntity.new(request, response)
|
163
|
+
when 502 then raise HttpClient::BadGateway.new(request, response)
|
157
164
|
when 503 then raise HttpClient::ServiceUnavailable.new(request, response)
|
158
165
|
else raise HttpClient::OtherHttpError.new(request, response)
|
159
166
|
end
|
@@ -73,6 +73,22 @@ RSpec.describe RestfulResource::HttpClient do
|
|
73
73
|
expect { http_client(connection).post('http://httpbin.org/status/422') }.to raise_error(RestfulResource::HttpClient::UnprocessableEntity)
|
74
74
|
end
|
75
75
|
|
76
|
+
it 'put should raise error 502' do
|
77
|
+
connection = faraday_connection do |stubs|
|
78
|
+
stubs.put('http://httpbin.org/status/502') { |env| [502, {}, nil] }
|
79
|
+
end
|
80
|
+
|
81
|
+
expect { http_client(connection).put('http://httpbin.org/status/502') }.to raise_error(RestfulResource::HttpClient::BadGateway)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'post should raise error 502' do
|
85
|
+
connection = faraday_connection do |stubs|
|
86
|
+
stubs.post('http://httpbin.org/status/502') { |env| [502, {}, nil] }
|
87
|
+
end
|
88
|
+
|
89
|
+
expect { http_client(connection).post('http://httpbin.org/status/502') }.to raise_error(RestfulResource::HttpClient::BadGateway)
|
90
|
+
end
|
91
|
+
|
76
92
|
it 'put should raise error 503' do
|
77
93
|
connection = faraday_connection do |stubs|
|
78
94
|
stubs.put('http://httpbin.org/status/503') { |env| [503, {}, nil] }
|