Chore: Enable errorlint linter (#29227)

* Enable errorlint linter
* Handle wrapped errors

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
This commit is contained in:
Arve Knudsen
2020-11-19 14:47:17 +01:00
committed by GitHub
parent 993adb72e0
commit 9593d57914
34 changed files with 142 additions and 101 deletions

View File

@ -1,6 +1,7 @@
package migrator
import (
"errors"
"fmt"
"strconv"
"strings"
@ -172,7 +173,8 @@ func (db *PostgresDialect) TruncateDBTables() error {
}
func (db *PostgresDialect) isThisError(err error, errcode string) bool {
if driverErr, ok := err.(*pq.Error); ok {
var driverErr *pq.Error
if errors.As(err, &driverErr) {
if string(driverErr.Code) == errcode {
return true
}
@ -182,7 +184,8 @@ func (db *PostgresDialect) isThisError(err error, errcode string) bool {
}
func (db *PostgresDialect) ErrorMessage(err error) string {
if driverErr, ok := err.(*pq.Error); ok {
var driverErr *pq.Error
if errors.As(err, &driverErr) {
return driverErr.Message
}
return ""