From 1860f5b6be2de437d92633d72a0a8d95f30d96fe Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Tue, 27 Feb 2024 14:47:57 -0800 Subject: [PATCH] Fix showing the query on the item search error page Previously, the query wouldn't fill into the search box or page title if e.g. parsing had failed. Now it does! I'm not sure why the rescue strategy we previously had here doesn't work anymore (I'm sure it must've in the past sometime?), but this is simpler anyway, let's go! --- app/controllers/items_controller.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 54662e8b..19ba6b64 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -130,6 +130,7 @@ class ItemsController < ApplicationController def search_error(e) @items = [] + @query = params[:q] respond_to do |format| format.html { flash.now[:alert] = e.message; render } format.json { render :json => {error: e.message} } @@ -139,14 +140,7 @@ class ItemsController < ApplicationController def set_query q = params[:q] if q.is_a?(String) - begin - @query = Item::Search::Query.from_text(q, current_user) - rescue - # Set the query string for error handling messages, but let the error - # bubble up. - @query = params[:q] - raise - end + @query = Item::Search::Query.from_text(q, current_user) elsif q.is_a?(ActionController::Parameters) @query = Item::Search::Query.from_params(q, current_user) end