Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontext.go
More file actions
Latest commit
41 lines (32 loc) · 847 Bytes
/
Copy pathcontext.go
File metadata and controls
41 lines (32 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package errors
import (
"context"
"github.com/pkg/errors"
)
// ContextError represents a standard error
// that can also encapsulate a context.
typeContextErrorstruct {
Errerror
Ctx context.Context//nolint:containedctx
}
funcWithContext(errerror, ctx context.Context) *ContextError {
return&ContextError{
Err: err,
Ctx: ctx,
}
}
funcWrapContext(errerror, ctx context.Context, messagestring) *ContextError {
returnWithContext(errors.Wrap(err, message), ctx)
}
funcWrapfContext(errerror, ctx context.Context, formatstring, args...any) *ContextError {
returnWithContext(errors.Wrapf(err, format, args...), ctx)
}
func (ce*ContextError) Error() string {
returnce.Err.Error()
}
func (ce*ContextError) Cause() error {
returnerrors.Cause(ce.Unwrap())
}
func (ce*ContextError) Unwrap() error {
returnce.Err
}