Business intelligence made simple
Use constant for timeout errors
Andrew Kaned308bf3fbce2
diff --git a/lib/blazer.rb b/lib/blazer.rbindex d817d76e..9b8d8099 100644--- a/lib/blazer.rb+++ b/lib/blazer.rb@@ -25,6 +25,11 @@ module Blazerself.check_schedules = ["1 day", "1 hour", "5 minutes"]TIMEOUT_MESSAGE = "Query timed out :("+ TIMEOUT_ERRORS = [+ "canceling statement due to statement timeout", # postgres+ "cancelled on user's request", # redshift+ "system requested abort" # redshift+ ]def self.time_zone=(time_zone)@time_zone = time_zone.is_a?(ActiveSupport::TimeZone) ? time_zone : ActiveSupport::TimeZone[time_zone.to_s]diff --git a/lib/blazer/data_source.rb b/lib/blazer/data_source.rbindex 2554bba7..e620628b 100644--- a/lib/blazer/data_source.rb+++ b/lib/blazer/data_source.rb@@ -99,7 +99,7 @@ module Blazerendrescue ActiveRecord::StatementInvalid => eerror = e.message.sub(/.+ERROR: /, "")- error = Blazer::TIMEOUT_MESSAGE if error.include?("canceling statement due to statement timeout") || error.include?("cancelled on user's request") || error.include?("system requested abort")+ error = Blazer::TIMEOUT_MESSAGE if Blazer::TIMEOUT_ERRORS.any? { |e| error.include?(e) }endend