From c0d381fc8f2fc733e3132ff8a0bee51ccbf98088 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Thu, 19 Feb 2015 11:54:49 -0600 Subject: [PATCH] Move exception handling code from invalid_solr_id_error to invalid_document_id_error --- lib/blacklight/catalog.rb | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/blacklight/catalog.rb b/lib/blacklight/catalog.rb index c54f8875fd..930cb56d37 100644 --- a/lib/blacklight/catalog.rb +++ b/lib/blacklight/catalog.rb @@ -297,29 +297,19 @@ def validate_email_params end ## - # when a request for /catalog/BAD_SOLR_ID is made, this method is executed. + # when a request for /catalog/BAD_ID is made, this method is executed. # Just returns a 404 response, but you can override locally in your own # CatalogController to do something else -- older BL displayed a Catalog#inde # page with a flash message and a 404 status. - def invalid_document_id_error *args - Deprecation.silence(Blacklight::Catalog) do - invalid_solr_id_error *args - end - end - - ## - # DEPRECATED; this method will be removed in Blacklight 6.0 and the functionality - # moved to invalid_document_id_error - def invalid_solr_id_error(exception) - Deprecation.warn Blacklight::Catalog, "#invalid_solr_id_error is deprecated; used #invalid_document_id_error instead" + def invalid_document_id_error exception error_info = { "status" => "404", "error" => "#{exception.class}: #{exception.message}" } respond_to do |format| - format.xml { render :xml => error_info, :status => 404 } - format.json { render :json => error_info, :status => 404 } + format.xml { render xml: error_info, status: 404 } + format.json { render json: error_info, status: 404 } # default to HTML response, even for other non-HTML formats we don't # neccesarily know about, seems to be consistent with what Rails4 does @@ -329,11 +319,19 @@ def invalid_solr_id_error(exception) # possibly non-html formats, this is consistent with what Rails does # on raising an ActiveRecord::RecordNotFound. Rails.root IS needed # for it to work under testing, without worrying about CWD. - render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false, :content_type => 'text/html' + render file: "#{Rails.root}/public/404.html", status: 404, layout: false, content_type: 'text/html' end end end + ## + # DEPRECATED; this method will be removed in Blacklight 6.0 and the functionality + # moved to invalid_document_id_error + def invalid_solr_id_error(exception) + Deprecation.warn Blacklight::Catalog, "#invalid_solr_id_error is deprecated; used #invalid_document_id_error instead" + invalid_document_id_error exception + end + def start_new_search_session? action_name == "index" end