Skip to content

Commit

Permalink
fix: log all database connection errors (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik authored May 6, 2021
1 parent fe273fa commit 2b0fad8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/persistence/sql/persister.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,17 @@ func (p *Persister) newConnection(options map[string]string) (c *pop.Connection,
if err := backoff.Retry(func() (err error) {
c, err = pop.NewConnection(connDetails)
if err != nil {
p.l.WithError(err).Warnf("Unable to connect to database, retrying.")
p.l.WithError(err).Error("Unable to connect to database, retrying.")
return errors.WithStack(err)
}

if err := c.Open(); err != nil {
p.l.WithError(err).Warnf("Unable to open the database connection, retrying.")
p.l.WithError(err).Error("Unable to open the database connection, retrying.")
return errors.WithStack(err)
}

if err := c.Store.(interface{ Ping() error }).Ping(); err != nil {
p.l.WithError(err).Error("Unable to ping the database connection, retrying.")
return errors.WithStack(err)
}

Expand Down

0 comments on commit 2b0fad8

Please sign in to comment.