diff --git a/terror/terror.go b/terror/terror.go index 91350dd72..b67304102 100644 --- a/terror/terror.go +++ b/terror/terror.go @@ -18,6 +18,7 @@ import ( "fmt" "strconv" + "github.com/modern-go/reflect2" "github.com/pingcap/errors" "github.com/pingcap/parser/mysql" log "github.com/sirupsen/logrus" @@ -213,10 +214,16 @@ func (e *Error) Location() (file string, line int) { // Error implements error interface. func (e *Error) Error() string { + if reflect2.IsNil(e) { + return "" + } return fmt.Sprintf("[%s:%d]%s", e.class, e.code, e.getMsg()) } func (e *Error) getMsg() string { + if reflect2.IsNil(e) { + return "" + } if len(e.args) > 0 { return fmt.Sprintf(e.message, e.args...) }