garage_client 2.1.5 → 2.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a245994587e4e1f2b358c5203e422a7c9423e298
4
- data.tar.gz: 6d1d413d48b1481b28655f27f98891f133fd037a
3
+ metadata.gz: 876435ec94b293955088ff468b9f15eda5a5f08d
4
+ data.tar.gz: 2aa489fb0250350d47c86c6751950d1db5a36743
5
5
  SHA512:
6
- metadata.gz: 60b1b286474cd550eff135c2e0320c3821b2267e21750108c0bac0fb3a615e05e3fd4fe45a0f8a585af46fc10cbec5018c405570cbec67f8b6f9b6204d751f52
7
- data.tar.gz: 53e11cf72c8418d7224eb68b1b28be5364cb80071d30b9d9241cf52ce6d6cac3dd150bc52b4ebc8e845f893d3803db6adb7a9797e31838ed17068d4387203c8e
6
+ metadata.gz: e7acdb469b6d4493aab2e86669c55c05f2209eea17c03eb9ef7dfc954f871ba8a7d7ed0beb94a451bef03e53a2bffee5480e48efde848c0da50afda07001bebe
7
+ data.tar.gz: e772d7c35be9afa30b6d04cab2abb3df81808e5429cccd1b9f48aa18662d143ba160ea60c560199aebe8bbd9cda1525b65f43103689ffc2437d5c15f58e98740
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 2.1.6
2
+ - Raise error on 4xx client errors or 5xx server errors.
3
+
1
4
  ## 2.1.5
2
5
  - Better error message for unexpected property access
3
6
  - Add `:timeout` and `:open_timeout` option
@@ -27,6 +27,8 @@ module GarageClient
27
27
  class Conflict < Error; end
28
28
  class UnsupportedMediaType < Error; end
29
29
  class UnprocessableEntity < Error; end
30
+ class ClientError < Error; end
31
+ class ServerError < Error; end
30
32
 
31
33
  # Remote Server
32
34
  class InternalServerError < Error; end
@@ -4,6 +4,9 @@ require 'faraday_middleware'
4
4
  module GarageClient
5
5
  class Response
6
6
  class RaiseHttpException < Faraday::Response::Middleware
7
+ ClientErrorStatuses = 400...500
8
+ ServerErrorStatuses = 500...600
9
+
7
10
  def call(env)
8
11
  @app.call(env).on_complete do |response|
9
12
  resp = response
@@ -28,6 +31,10 @@ module GarageClient
28
31
  raise GarageClient::InternalServerError.new(resp)
29
32
  when 503
30
33
  raise GarageClient::ServiceUnavailable.new(resp)
34
+ when ClientErrorStatuses
35
+ raise GarageClient::ClientError.new(resp)
36
+ when ServerErrorStatuses
37
+ raise GarageClient::ServerError.new(resp)
31
38
  end
32
39
  end
33
40
  end
@@ -1,3 +1,3 @@
1
1
  module GarageClient
2
- VERSION = '2.1.5'
2
+ VERSION = '2.1.6'
3
3
  end
@@ -437,6 +437,13 @@ describe Faraday::Response do
437
437
  422 => GarageClient::UnprocessableEntity,
438
438
  500 => GarageClient::InternalServerError,
439
439
  503 => GarageClient::ServiceUnavailable,
440
+
441
+ 402 => GarageClient::ClientError,
442
+ 405 => GarageClient::ClientError,
443
+ 407 => GarageClient::ClientError,
444
+ 408 => GarageClient::ClientError,
445
+ 502 => GarageClient::ServerError,
446
+ 504 => GarageClient::ServerError,
440
447
  }.each do |status, exception|
441
448
  context "when HTTP status is #{status}" do
442
449
  before do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garage_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cookpad Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-27 00:00:00.000000000 Z
11
+ date: 2016-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  version: '0'
244
244
  requirements: []
245
245
  rubyforge_project:
246
- rubygems_version: 2.5.1
246
+ rubygems_version: 2.4.5.1
247
247
  signing_key:
248
248
  specification_version: 4
249
249
  summary: Ruby client library for the Garage API