优化错误提示

This commit is contained in:
GoEdgeLab
2023-04-04 15:56:44 +08:00
parent 46a789870c
commit 790165c73a

View File

@@ -29,8 +29,12 @@ func (this *errorObj) Error() string {
return s return s
} }
// 新错误 // New 新错误
func New(errText string) error { func New(errText string) error {
if !Tea.IsTesting() {
return errors.New(errText)
}
ptr, file, line, ok := runtime.Caller(1) ptr, file, line, ok := runtime.Caller(1)
funcName := "" funcName := ""
if ok { if ok {
@@ -45,7 +49,7 @@ func New(errText string) error {
} }
} }
// 包装已有错误 // Wrap 包装已有错误
func Wrap(err error) error { func Wrap(err error) error {
if err == nil { if err == nil {
return nil return nil