mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-29 09:16:35 +08:00
去除错误提示中的程序文件名中的Workspace目录
This commit is contained in:
@@ -2,6 +2,7 @@ package errors
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
@@ -15,7 +16,7 @@ type errorObj struct {
|
||||
}
|
||||
|
||||
func (this *errorObj) Error() string {
|
||||
s := this.err.Error() + "\n " + this.file
|
||||
s := this.err.Error() + "\n " + utils.RemoveWorkspace(this.file)
|
||||
if len(this.funcName) > 0 {
|
||||
s += ":" + this.funcName + "()"
|
||||
}
|
||||
@@ -23,7 +24,7 @@ func (this *errorObj) Error() string {
|
||||
return s
|
||||
}
|
||||
|
||||
// 新错误
|
||||
// New 新错误
|
||||
func New(errText string) error {
|
||||
ptr, file, line, ok := runtime.Caller(1)
|
||||
funcName := ""
|
||||
@@ -39,7 +40,7 @@ func New(errText string) error {
|
||||
}
|
||||
}
|
||||
|
||||
// 包装已有错误
|
||||
// Wrap 包装已有错误
|
||||
func Wrap(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user