errors.Format

This commit is contained in:
Darien Raymond
2016-12-15 11:05:32 +01:00
parent 49202930ff
commit 5bbbdc05de
6 changed files with 15 additions and 11 deletions
+7 -1
View File
@@ -2,6 +2,7 @@ package errors
import (
"fmt"
"v2ray.com/core/common/serial"
)
@@ -27,7 +28,7 @@ func (v *Error) Inner() error {
func New(msg ...interface{}) error {
return &Error{
message: serial.ToString(msg),
message: serial.Concat(msg),
}
}
@@ -37,6 +38,11 @@ func Base(err error) ErrorBuilder {
}
}
func Format(format string, values ...interface{}) error {
return New(fmt.Sprintf(format, values...))
}
// Cause returns the root cause of this error.
func Cause(err error) error {
if err == nil {
return nil