Skip to content

Commit

Permalink
try set nil
Browse files Browse the repository at this point in the history
  • Loading branch information
comomac committed Mar 11, 2022
1 parent 5d452af commit c900f97
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions terror.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

// baseVersion actual version of terror module
const baseVersion string = "v2.0.8"
const baseVersion string = "v2.0.9"

// ErrKind Kind of error
type ErrKind string
Expand Down Expand Up @@ -165,12 +165,13 @@ func SetCallbackPanic(callback funcExec) {
}

// Error returns TError with level error
func Error(err error, friendlyMessage ...string) *TError {
func Error(err error, friendlyMessage ...string) (x *TError) {
// deals with accidental error == nil
if err == nil {
pc, file, line, _ := runtime.Caller(1)
funcName := runtime.FuncForPC(pc).Name()
fmt.Printf("WARN Error(err) is nil \033[1;34m%s\033[0m[%s:%d]\n", funcName, file, line)
x = nil
return nil
}

Expand Down

0 comments on commit c900f97

Please sign in to comment.