@@ -25,30 +25,41 @@ func (err ErrCtx) Unwrap() error {
25
25
return err .err
26
26
}
27
27
28
- func New (ctx context.Context , message string ) error {
29
- return ErrCtx {ctx : ctx , err : errgo .New (message )}
28
+ // New wraps errors.New from the pkg/errors library
29
+ //
30
+ // These errors are usually created outside any function code at the top of
31
+ // files, so no context is needed.
32
+ func New (message string ) error {
33
+ return errors .New (message )
34
+ }
35
+
36
+ func NewWithCtx (ctx context.Context , message string ) error {
37
+ return ErrCtx {ctx : ctx , err : errors .New (message )}
30
38
}
31
39
32
40
func Newf (ctx context.Context , format string , args ... interface {}) error {
33
- return ErrCtx {ctx : ctx , err : errgo . Newf (format , args ... )}
41
+ return ErrCtx {ctx : ctx , err : errors . Errorf (format , args ... )}
34
42
}
35
43
44
+ func Errorf (ctx context.Context , format string , args ... interface {}) error {
45
+ return ErrCtx {ctx : ctx , err : errors .Errorf (format , args ... )}
46
+ }
47
+
48
+ // Notef is wrapping an error with the underneath errgo library
36
49
func Notef (ctx context.Context , err error , format string , args ... interface {}) error {
37
50
return ErrCtx {ctx : ctx , err : errgo .Notef (err , format , args ... )}
38
51
}
39
52
53
+ // Wrap is wrapping an error with the underneath errgo library
40
54
func Wrap (ctx context.Context , err error , message string ) error {
41
55
return ErrCtx {ctx : ctx , err : errors .Wrap (err , message )}
42
56
}
43
57
58
+ // Wrapf is wrapping an error with the underneath errgo library
44
59
func Wrapf (ctx context.Context , err error , format string , args ... interface {}) error {
45
60
return ErrCtx {ctx : ctx , err : errors .Wrapf (err , format , args ... )}
46
61
}
47
62
48
- func Errorf (ctx context.Context , format string , args ... interface {}) error {
49
- return ErrCtx {ctx : ctx , err : errors .Errorf (format , args ... )}
50
- }
51
-
52
63
// RootCtxOrFallback unwrap all wrapped errors from err to get the deepest context
53
64
// from ErrCtx errors. If there is no wrapped ErrCtx RootCtxOrFallback returns ctx from parameter.
54
65
func RootCtxOrFallback (ctx context.Context , err error ) context.Context {
0 commit comments