|
|
@ -4,6 +4,7 @@ package errors // import "v2ray.com/core/common/errors" |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"reflect" |
|
|
|
"reflect" |
|
|
|
|
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
|
|
"v2ray.com/core/common/log" |
|
|
|
"v2ray.com/core/common/log" |
|
|
|
"v2ray.com/core/common/serial" |
|
|
|
"v2ray.com/core/common/serial" |
|
|
@ -41,21 +42,28 @@ func (err *Error) pkgPath() string { |
|
|
|
|
|
|
|
|
|
|
|
// Error implements error.Error().
|
|
|
|
// Error implements error.Error().
|
|
|
|
func (v *Error) Error() string { |
|
|
|
func (v *Error) Error() string { |
|
|
|
msg := serial.Concat(v.message...) |
|
|
|
builder := strings.Builder{} |
|
|
|
if v.inner != nil { |
|
|
|
for _, prefix := range v.prefix { |
|
|
|
msg += " > " + v.inner.Error() |
|
|
|
builder.WriteByte('[') |
|
|
|
|
|
|
|
builder.WriteString(serial.ToString(prefix)) |
|
|
|
|
|
|
|
builder.WriteString("] ") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
path := v.pkgPath() |
|
|
|
path := v.pkgPath() |
|
|
|
if len(path) > 0 { |
|
|
|
if len(path) > 0 { |
|
|
|
msg = path + ": " + msg |
|
|
|
builder.WriteString(path) |
|
|
|
|
|
|
|
builder.WriteString(": ") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var prefix string |
|
|
|
msg := serial.Concat(v.message...) |
|
|
|
for _, p := range v.prefix { |
|
|
|
builder.WriteString(msg) |
|
|
|
prefix += "[" + serial.ToString(p) + "] " |
|
|
|
|
|
|
|
|
|
|
|
if v.inner != nil { |
|
|
|
|
|
|
|
builder.WriteString(" > ") |
|
|
|
|
|
|
|
builder.WriteString(v.inner.Error()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return prefix + msg |
|
|
|
return builder.String() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Inner implements hasInnerError.Inner()
|
|
|
|
// Inner implements hasInnerError.Inner()
|
|
|
|