瀏覽代碼

Friendlier timeout message

Andrew Kane 8 年之前
父節點
當前提交
b9528b3c12
共有 3 個文件被更改,包括 4 次插入1 次删除
  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