slimmer 15.2.0 → 15.3.0

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
  SHA256:
3
- metadata.gz: adfdc8dd1fa7b69450bbbae9daf9cbd352704a621947aad067fc5aabad239132
4
- data.tar.gz: ef11b30a4f27806579d0a7e690f9e71b08210d10625722de29b6a320d5cf1840
3
+ metadata.gz: 5423f67907cfbc074dcc3ec3be3763ee1b4de7194746d3465e2bd8962f131589
4
+ data.tar.gz: 9378a917a3a686ac18dda3d401596ff3c749f2c45897409cf9ca79af02d19005
5
5
  SHA512:
6
- metadata.gz: 75bba48992276cc1d656c72271dd6ecb192af0467205cfc12411a8b53b26d65d534f25801b5e70b4a0304fbf08fa6202440891956bd36547f03dc488ec1aee64
7
- data.tar.gz: '038f855917b3f9fe4d66c0e15737efadd8b4724e23b47dab25573f18962e0b525449780566421f8b07759d17bda1947bdbc1e75ef032752645126fda9a3378d3'
6
+ metadata.gz: 0e5d62fedf19a951a60d82df37a9b3ca5258b2f46bc8e521e44050e00ff4755681f07ef6b5a540ea72702d5a5ae86fdd4792b86b9feeff07c1dd47dd075ea085
7
+ data.tar.gz: 79a18ae53ba25f1d3c3dacb186b1b7d239457b4a3201aad806aefad5547e55368021acdc94c46d35ad479686777c07ee88bf3a7a145237e7f64413b0bd13dd49
@@ -1,3 +1,8 @@
1
+ # 15.3.0
2
+
3
+ * Introduce separate, internal exception class for intermittent
4
+ template retrieval errors.
5
+
1
6
  # 15.2.0
2
7
 
3
8
  * Add X-Slimmer-Show-Accounts header to choose between accounts
@@ -45,6 +45,7 @@ module Slimmer
45
45
  autoload :TitleInserter, "slimmer/processors/title_inserter"
46
46
  end
47
47
 
48
- class TemplateNotFoundException < StandardError; end
49
48
  class CouldNotRetrieveTemplate < StandardError; end
49
+ class TemplateNotFoundException < CouldNotRetrieveTemplate; end
50
+ class IntermittentRetrievalError < CouldNotRetrieveTemplate; end
50
51
  end
@@ -22,10 +22,18 @@ module Slimmer
22
22
  def load_template(template_name)
23
23
  url = template_url(template_name)
24
24
  HTTPClient.get(url)
25
- rescue RestClient::Exception => e
26
- raise TemplateNotFoundException, "Unable to fetch: '#{template_name}' from '#{url}' because #{e}", caller
27
- rescue Errno::ECONNREFUSED, SocketError, OpenSSL::SSL::SSLError => e
28
- raise CouldNotRetrieveTemplate, "Unable to fetch: '#{template_name}' from '#{url}' because #{e}", caller
25
+ rescue Errno::ECONNREFUSED, SocketError, OpenSSL::SSL::SSLError, RestClient::Exception => e
26
+ message = "Unable to fetch: '#{template_name}' from '#{url}' because #{e}"
27
+
28
+ if e.is_a?(RestClient::Exception) && e.http_code == 404
29
+ raise TemplateNotFoundException, message, caller
30
+ end
31
+
32
+ if e.is_a?(RestClient::Exception) && [502, 503, 504].include?(e.http_code)
33
+ raise IntermittentRetrievalError, message, caller
34
+ end
35
+
36
+ raise CouldNotRetrieveTemplate, message, caller
29
37
  end
30
38
 
31
39
  def template_url(template_name)
@@ -1,3 +1,3 @@
1
1
  module Slimmer
2
- VERSION = "15.2.0".freeze
2
+ VERSION = "15.3.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.2.0
4
+ version: 15.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-28 00:00:00.000000000 Z
11
+ date: 2020-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport