Skip to content

Commit

Permalink
Merge pull request #458 from Scalingo/fix/errctx/457/noteMask_take_a_…
Browse files Browse the repository at this point in the history
…func_as_param

fix(errctx): remove NoteMask, `Notef` should be use instead
  • Loading branch information
EtienneM authored Jan 5, 2023
2 parents c991462 + 853747f commit 0ca6fcb
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 57 deletions.
2 changes: 2 additions & 0 deletions errors/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## To be Released

* fix: remove `NoteMask`. `Notef` should be use instead.

## v2.2.0

* feat: add UnwrapError to unwrap one error.
Expand Down
53 changes: 0 additions & 53 deletions errors/cause_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ func Test_IsRootCause(t *testing.T) {
assert.False(t, IsRootCause(err, ValidationErrors{}))
})

t.Run("given an error stack with errgo.NoteMask", func(t *testing.T) {
var err error
err = (&ValidationErrors{})
err = errgo.NoteMask(err, "biniou")

assert.True(t, IsRootCause(err, &ValidationErrors{}))
assert.False(t, IsRootCause(err, ValidationErrors{}))
})

t.Run("given an error stack with errors.Wrap", func(t *testing.T) {
var err error
err = (&ValidationErrors{})
Expand Down Expand Up @@ -73,14 +64,6 @@ func Test_IsRootCause(t *testing.T) {
assert.False(t, IsRootCause(err, ValidationErrors{}))
})

t.Run("given an error stack with NoteMask from ErrCtx", func(t *testing.T) {
var err error
err = (&ValidationErrors{})
err = NoteMask(context.Background(), err, "biniou")

assert.True(t, IsRootCause(err, &ValidationErrors{}))
assert.False(t, IsRootCause(err, ValidationErrors{}))
})
}

func Test_RootCause(t *testing.T) {
Expand Down Expand Up @@ -108,18 +91,6 @@ func Test_RootCause(t *testing.T) {
assert.Equal(t, "test=biniou", RootCause(err).Error())
})

t.Run("given an error stack with errgo.NoteMask", func(t *testing.T) {
var err error
err = (&ValidationErrors{
Errors: map[string][]string{
"test": {"biniou"},
},
})
err = errgo.NoteMask(err, "pouet")

assert.Equal(t, "test=biniou", RootCause(err).Error())
})

t.Run("given an error stack with errors.Wrap", func(t *testing.T) {
var err error
err = (&ValidationErrors{
Expand Down Expand Up @@ -167,18 +138,6 @@ func Test_RootCause(t *testing.T) {

assert.Equal(t, "test=biniou", RootCause(err).Error())
})

t.Run("given an error stack with NoteMask from ErrCtx", func(t *testing.T) {
var err error
err = (&ValidationErrors{
Errors: map[string][]string{
"test": {"biniou"},
},
})
err = NoteMask(context.Background(), err, "pouet")

assert.Equal(t, "test=biniou", RootCause(err).Error())
})
}

func Test_UnwrapError(t *testing.T) {
Expand Down Expand Up @@ -215,18 +174,6 @@ func Test_UnwrapError(t *testing.T) {
assert.Equal(t, "test=biniou", lastErr.Error())
})

t.Run("given an error stack with NoteMask from ErrCtx", func(t *testing.T) {
var err error
err = (&ValidationErrors{
Errors: map[string][]string{
"test": {"biniou"},
},
})
err = NoteMask(context.Background(), err, "pouet")

assert.Equal(t, "pouet: test=biniou", UnwrapError(err).Error())
})

t.Run("given an error stack with Notef from ErrCtx", func(t *testing.T) {
var err error
err = (&ValidationErrors{
Expand Down
4 changes: 0 additions & 4 deletions errors/errctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ func Newf(ctx context.Context, format string, args ...interface{}) error {
return ErrCtx{ctx: ctx, err: errgo.Newf(format, args...)}
}

func NoteMask(ctx context.Context, err error, message string) error {
return ErrCtx{ctx: ctx, err: errgo.NoteMask(err, message)}
}

func Notef(ctx context.Context, err error, format string, args ...interface{}) error {
return ErrCtx{ctx: ctx, err: errgo.Notef(err, format, args...)}
}
Expand Down

0 comments on commit 0ca6fcb

Please sign in to comment.