优化错误处理相关代码

This commit is contained in:
刘祥超
2023-08-11 16:13:33 +08:00
parent 034ababead
commit d1ba141c65
19 changed files with 81 additions and 68 deletions

View File

@@ -2,6 +2,7 @@ package rpcutils
import (
"errors"
"fmt"
)
type UserType = string
@@ -27,5 +28,5 @@ func Wrap(description string, err error) error {
if err == nil {
return errors.New(description)
}
return errors.New(description + ": " + err.Error())
return fmt.Errorf("%s: %w", description, err)
}