Skip to content

Commit 0587ac7

Browse files
committed
chore: handle BadRequests
1 parent a644a46 commit 0587ac7

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

app/controllers/application_controller.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ class ApplicationController < ActionController::Base
1111

1212
helper_method :signed_in?, :current_user
1313

14-
rescue_from ActiveRecord::RecordNotFound, with: :_404
15-
rescue_from ActionView::MissingTemplate, with: :_404
16-
rescue_from ActionController::UnknownFormat, with: :_404
14+
rescue_from ActiveRecord::RecordNotFound, with: :_404
15+
rescue_from ActionView::MissingTemplate, with: :_404
16+
rescue_from ActionController::UnknownFormat, with: :_404
17+
rescue_from ActionController::BadRequest, with: :_400
1718

1819
expose(:jobs) { Job.shuffled }
1920
expose(:highlights) { Highlight.active }
@@ -25,6 +26,11 @@ def setup
2526
switch_time_zone
2627
end
2728

29+
def _400(exception)
30+
Rails.logger.warn "400 bad_request: #{exception.message}#{request.method} #{request.path} (#{request.remote_ip})"
31+
head(:bad_request)
32+
end
33+
2834
def _404(exception)
2935
Rails.logger.warn exception
3036
Rails.logger.warn "head 404 with params #{params}"

0 commit comments

Comments
 (0)