From: Tom Hughes Date: Tue, 16 Nov 2021 12:44:52 +0000 (+0000) Subject: Send plain errors for non HTML resources X-Git-Tag: live~1874 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/02fb858956615e730ae6e93fcd4c287824bf9284 Send plain errors for non HTML resources Without this we throw a second error when we can't find a view of the correct format and issue a 500 response. --- diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index 3bc958615..caadd5121 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -4,14 +4,23 @@ class ErrorsController < ApplicationController skip_authorization_check def forbidden - render :status => :forbidden + respond_to do |format| + format.html { render :status => :forbidden } + format.any { render :status => :forbidden, :plain => "" } + end end def not_found - render :status => :not_found + respond_to do |format| + format.html { render :status => :not_found } + format.any { render :status => :not_found, :plain => "" } + end end def internal_server_error - render :status => :internal_server_error + respond_to do |format| + format.html { render :status => :internal_server_error } + format.any { render :status => :internal_server_error, :plain => "" } + end end end