Skip to content

Commit

Permalink
add WrapContext and WrapfContext
Browse files Browse the repository at this point in the history
  • Loading branch information
gimmyxd committed May 7, 2024
1 parent 94705ea commit e05744d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions context_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package errors

import (
"context"

"github.com/pkg/errors"
)

// ContextError represents a standard error
Expand All @@ -18,6 +20,14 @@ func WrapWithContext(err error, ctx context.Context) *ContextError {
}
}

func WrapConext(err error, ctx context.Context, message string) *ContextError {
return WrapWithContext(errors.Wrap(err, message), ctx)
}

func WrapfConext(err error, ctx context.Context, format string, args ...interface{}) *ContextError {
return WrapWithContext(errors.Wrapf(err, format, args...), ctx)
}

func (ce *ContextError) Error() string {
return ce.Err.Error()
}
Expand Down

0 comments on commit e05744d

Please sign in to comment.