Audit all call sites where `fmt.Errorf()` was being used and switch to errwrap.

This commit is contained in:
Sean Chittenden 2016-12-27 15:37:30 -08:00
parent 9ab60ecc7b
commit 4570460f4e
No known key found for this signature in database
GPG Key ID: 4EBC9DC16C2E5E16
2 changed files with 3 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import (
"sync" "sync"
"unicode" "unicode"
"github.com/hashicorp/errwrap"
_ "github.com/lib/pq" //PostgreSQL db _ "github.com/lib/pq" //PostgreSQL db
) )
@ -89,7 +90,7 @@ func (c *Config) NewClient() (*Client, error) {
func (c *Client) Connect() (*sql.DB, error) { func (c *Client) Connect() (*sql.DB, error) {
db, err := sql.Open("postgres", c.connStr) db, err := sql.Open("postgres", c.connStr)
if err != nil { if err != nil {
return nil, fmt.Errorf("Error connecting to PostgreSQL server: %v", err) return nil, errwrap.Wrapf("Error connecting to PostgreSQL server: {{err}}", err)
} }
return db, nil return db, nil

View File

@ -374,7 +374,7 @@ func resourcePostgreSQLRoleReadImpl(d *schema.ResourceData, meta interface{}) er
err = conn.QueryRow("SELECT COALESCE(passwd, '') FROM pg_catalog.pg_shadow AS s WHERE s.usename = $1", roleId).Scan(&rolePassword) err = conn.QueryRow("SELECT COALESCE(passwd, '') FROM pg_catalog.pg_shadow AS s WHERE s.usename = $1", roleId).Scan(&rolePassword)
switch { switch {
case err == sql.ErrNoRows: case err == sql.ErrNoRows:
return fmt.Errorf("PostgreSQL role (%s) not found in shadow database: {{err}}", roleId) return errwrap.Wrapf(fmt.Errorf("PostgreSQL role (%s) not found in shadow database: {{err}}", roleId), err)
case err != nil: case err != nil:
return errwrap.Wrapf("Error reading role: {{err}}", err) return errwrap.Wrapf("Error reading role: {{err}}", err)
default: default: