Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate github.com/pkg/errors #58

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading