diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index b4ed5a5fd..5f5f11852 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -10,6 +10,13 @@ class PostsController < ApplicationController respond_with(@posts) do |format| format.atom end + rescue ::ActiveRecord::StatementInvalid => e + if e.to_s =~ /statement timeout/ + @error_message = "The database timed out running your query. Try a simpler query that returns fewer results." + render :action => "error" + else + raise + end end def show diff --git a/app/views/posts/error.html.erb b/app/views/posts/error.html.erb index 03a41e20c..3225ebc2e 100644 --- a/app/views/posts/error.html.erb +++ b/app/views/posts/error.html.erb @@ -1 +1,5 @@ -

Error: <%= @exception.to_s %>

\ No newline at end of file +<% if @error_message %> +

<%= @error_message %>

+<% else %> +

Error: <%= @exception.to_s %>

+<% end %> \ No newline at end of file