lib/gitlab_exporter/database/base.rb in gitlab-exporter-7.0.6 vs lib/gitlab_exporter/database/base.rb in gitlab-exporter-7.1.0

- old
+ new

@@ -14,12 +14,13 @@ PG.connect(connection_string) end end end - def initialize(args) + def initialize(args, logger: nil) @connection_string = args[:connection_string] + @logger = logger end def run fail NotImplemented end @@ -31,13 +32,17 @@ def with_connection_pool connection_pool.with do |conn| begin yield conn rescue PG::UnableToSend => e + @logger.warn "Error sending to the database: #{e}" if @logger conn.reset raise e end end + rescue PG::Error => e + @logger.error "Error connecting to the database: #{e}" if @logger + raise e end end end end end