Skip to content

Commit c227f42

Browse files
committed
error: add New function
1 parent ba65da3 commit c227f42

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

error.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,18 @@ func (e *Error) Unwrap() error {
9191
return e.err
9292
}
9393

94+
// New builds a Error struct for the suppied message and code.
95+
func New(c Code, args ...interface{}) *Error {
96+
e := &Error{
97+
Code: c,
98+
Message: fmt.Sprint(args...),
99+
frame: xerrors.Caller(1),
100+
}
101+
e.err = xerrors.New(e.Message)
102+
103+
return e
104+
}
105+
94106
// Errorf builds a Error struct for the suppied message and code.
95107
func Errorf(c Code, format string, args ...interface{}) *Error {
96108
e := &Error{

0 commit comments

Comments
 (0)