Revert "Allow NotFound to specify an optional Location for the resource"

This reverts commit 4ae66c9e01.
This commit is contained in:
Robin Ward 2017-09-26 12:58:15 -04:00
parent e687a1e8e3
commit 460ed3c8cf
2 changed files with 3 additions and 25 deletions

View File

@ -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

View File

@ -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