Skip to content

Commit 7b3a1cc

Browse files
committed
Add more accurate BadRequest handling
- Currently bad requests are getting intercepted by some default method that translates them into 503s. Add explict capture.
1 parent 0f11cb8 commit 7b3a1cc

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

app/controllers/application_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class ApplicationController < ActionController::Base
99
rescue_from GdsApi::HTTPNotFound, with: :cacheable_404
1010
rescue_from GdsApi::InvalidUrl, with: :cacheable_404
1111
rescue_from GdsApi::HTTPForbidden, with: :error_403
12+
rescue_from GdsApi::HTTPBadRequest, with: :error_400
1213
rescue_from RecordNotFound, with: :cacheable_404
1314

1415
# Because this code contains an if statement evaluated on Rails load and is just
@@ -27,6 +28,10 @@ class ApplicationController < ActionController::Base
2728

2829
helper_method :content_item
2930

31+
def error_400
32+
error :bad_request
33+
end
34+
3035
def error_403
3136
error :forbidden
3237
end

lib/content_item_loader.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def load_from_sources(base_path)
3232
end
3333

3434
default_loader.load(base_path:)
35-
rescue GdsApi::HTTPErrorResponse, GdsApi::InvalidUrl => e
35+
rescue GdsApi::HTTPErrorResponse, GdsApi::InvalidUrl, GdsApi::HTTPBadRequest => e
3636
e
3737
end
3838

0 commit comments

Comments
 (0)