diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b1359ffc2..9bee200f3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -47,7 +47,7 @@ class ApplicationController < ActionController::Base def rescue_exception(exception) case exception when ActiveRecord::QueryCanceled - render_error_page(500, exception, message: "The database timed out running your query.") + render_error_page(500, exception, template: "static/search_timeout", message: "The database timed out running your query.") when ActionController::BadRequest render_error_page(400, exception) when SessionLoader::AuthenticationFailure diff --git a/app/views/static/search_timeout.html.erb b/app/views/static/search_timeout.html.erb new file mode 100644 index 000000000..2c65343cd --- /dev/null +++ b/app/views/static/search_timeout.html.erb @@ -0,0 +1,55 @@ +
Your search took too long to execute and was cancelled.
+ ++ Some kinds of searches are slower than others. If your search is too slow + it may be cancelled. Usually this happens when your search is too + complex, or when there aren't many recent posts matching your search. +
+ + <% if params[:controller] == "posts" && params[:action] == "index" && params[:tags].present? %> +Try changing your search:
+ ++
| <%= link_to "#{params[:tags]} age:<1month", posts_url(tags: "#{params[:tags]} age:<1month") %> | +Search recent posts only. | +
| <%= link_to "#{params[:tags]} order:score", posts_url(tags: "#{params[:tags]} order:score") %> | +Order by score instead of by date. | +
| <%= link_to "#{params[:tags]} limit:5", posts_url(tags: "#{params[:tags]} limit:5") %> | +Show fewer posts per page. | +
+ Members are limited to searches that take up to 3 seconds long. You can + <%= link_to "upgrade your account", new_user_upgrade_path %> to increase + your search limit. Gold users can do searches that take up to 6 seconds + long, and Platinum users can go up to 9 seconds. +
+ <% end %> + + <%= link_to "Go back", :back, rel: "prev" %> +