Skip to content

Commit

Permalink
Merge pull request #58 from dmarkhas/deprecate_pkg_errors
Browse files Browse the repository at this point in the history
deprecate github.com/pkg/errors
  • Loading branch information
dmarkhas authored Jul 25, 2024
2 parents dc9ea3a + 9157c26 commit 07a3b5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ func TestRegisterDeregister(t *testing.T) {
assert.False(t, failingCheck.IsHealthy(), "check initially fails until first execution by default")
assert.True(t, initiallyPassingCheck.IsHealthy(), "check should initially pass")
assert.Contains(t, passingCheck.String(), "didn't run yet", "initial details")
assert.EqualError(t, passingCheck.Error, gosundheit.ErrNotRunYet.Error(), "initial details")
assert.True(t, errors.Is(passingCheck.Error, gosundheit.ErrNotRunYet))
assert.Contains(t, failingCheck.String(), "didn't run yet", "initial details")
assert.EqualError(t, failingCheck.Error, gosundheit.ErrNotRunYet.Error(), "initial details")
assert.True(t, errors.Is(failingCheck.Error, gosundheit.ErrNotRunYet))
assert.Contains(t, initiallyPassingCheck.String(), "didn't run yet", "initial details")

// await first execution
Expand Down
16 changes: 6 additions & 10 deletions types.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package gosundheit

import (
"errors"
"fmt"
"time"

"github.com/pkg/errors"
)

const (
maxExpectedChecks = 16
// ValAllChecks is the value used for the check tags when tagging all tests
ValAllChecks = "all_checks"
)

var (
ErrNotRunYet = errors.New("didn't run yet")
ErrNotRunYet = newMarshalableError(errors.New("didn't run yet"))
)

// Result represents the output of a health check execution.
Expand Down Expand Up @@ -53,18 +50,17 @@ func newMarshalableError(err error) error {
return nil
}

mr := &marshalableError{
mr := marshalableError{
Message: err.Error(),
}

cause := errors.Cause(err)
if cause != err {
cause := errors.Unwrap(err)
if !errors.Is(cause, err) {
mr.Cause = newMarshalableError(cause)
}

return mr
}

func (e *marshalableError) Error() string {
func (e marshalableError) Error() string {
return e.Message
}

0 comments on commit 07a3b5e

Please sign in to comment.