Browse Source

Friendlier timeout message

Andrew Kane 8 years ago
parent
commit
b9528b3c12
3 changed files with 4 additions and 1 deletions
  1. 1 1
      app/controllers/blazer/queries_controller.rb
  2. 2 0
      lib/blazer.rb
  3. 1 0
      lib/blazer/data_source.rb

+ 1 - 1
app/controllers/blazer/queries_controller.rb

@@ -79,7 +79,7 @@ module Blazer
 
         @rows, @error, @cached_at = @data_source.run_statement(@statement, user: blazer_user, query: @query, refresh_cache: params[:check])
 
-        if @query && !@error.to_s.include?("canceling statement due to statement timeout")
+        if @query && @error != Blazer::TIMEOUT_MESSAGE
           @query.checks.each do |check|
             check.update_state(@rows, @error)
           end

+ 2 - 0
lib/blazer.rb

@@ -20,6 +20,8 @@ module Blazer
   self.audit = true
   self.user_name = :name
 
+  TIMEOUT_MESSAGE = "Query timed out :("
+
   def self.time_zone=(time_zone)
     @time_zone = time_zone.is_a?(ActiveSupport::TimeZone) ? time_zone : ActiveSupport::TimeZone[time_zone.to_s]
   end

+ 1 - 0
lib/blazer/data_source.rb

@@ -82,6 +82,7 @@ module Blazer
             end
           rescue ActiveRecord::StatementInvalid => e
             error = e.message.sub(/.+ERROR: /, "")
+            error = Blazer::TIMEOUT_MESSAGE if error.include?("canceling statement due to statement timeout") || error.include?("cancelled on user's request")
           end
         end