diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index dc08d6b8e5e..6ec126ac1b4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -136,15 +136,7 @@ class ApplicationController < ActionController::Base end end - rescue_from Discourse::NotFound do |e| - rescue_discourse_actions( - :not_found, - 404, - location: e.location - ) - end - - rescue_from PluginDisabled do |e| + rescue_from Discourse::NotFound, PluginDisabled do rescue_discourse_actions(:not_found, 404) end @@ -167,18 +159,10 @@ class ApplicationController < ActionController::Base (request.xhr?) || ((params[:external_id] || '').ends_with? '.json') - if opts[:location] - response.headers['Location'] = opts[:location] - end - if show_json_errors # HACK: do not use render_json_error for topics#show if request.params[:controller] == 'topics' && request.params[:action] == 'show' - return render( - status: status_code, - layout: false, - text: (status_code == 404 || status_code == 410) ? build_not_found_page(status_code) : I18n.t(type) - ) + return render status: status_code, layout: false, text: (status_code == 404 || status_code == 410) ? build_not_found_page(status_code) : I18n.t(type) end render_json_error I18n.t(opts[:custom_message] || type), type: type, status: status_code diff --git a/lib/discourse.rb b/lib/discourse.rb index 7d748a955fd..dfcc1a90bd6 100644 --- a/lib/discourse.rb +++ b/lib/discourse.rb @@ -74,13 +74,7 @@ module Discourse end # When something they want is not found - class NotFound < StandardError - attr_reader :location - def initialize(opts = nil) - opts ||= {} - @location = opts[:location] - end - end + class NotFound < StandardError; end # When a setting is missing class SiteSettingMissing < StandardError; end