Skip to content

Commit

Permalink
fix build version issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Weber committed Jan 8, 2025
1 parent a4ce0fd commit d594a9f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 34 deletions.
11 changes: 4 additions & 7 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ import (
//
// You can also use the StackTracer interface on the returned error to get the stack trace.
func GetStackTracer(origErr error) stackfmt.StackTracer {
var stacked stackfmt.StackTracer
errwrap.WalkDeep(origErr, func(err error) bool {
for err := range errwrap.UnwrapGroups(origErr) {
if stackTracer, ok := err.(stackfmt.StackTracer); ok {
stacked = stackTracer
return true
return stackTracer
}
return false
})
return stacked
}
return nil
}

// IsNil performs additional checks besides == nil
Expand Down
26 changes: 0 additions & 26 deletions errwrap/go_123_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"strconv"
"testing"
)

Expand Down Expand Up @@ -116,31 +115,6 @@ func ExampleUnwrapGroups() {
// error 2
}

type errWalkTest struct {
cause error
sub []error
v int
}

func (e *errWalkTest) Error() string {
return strconv.Itoa(e.v)
}

func (e *errWalkTest) Unwrap() error {
return e.cause
}

func (e *errWalkTest) Errors() []error {
return e.sub
}

func testFind(err error, v int) bool {
return WalkDeep(err, func(err error) bool {
e := err.(*errWalkTest)
return e.v == v
})
}

func TestWalkDeep(t *testing.T) {
err := &errWalkTest{
sub: []error{
Expand Down
25 changes: 25 additions & 0 deletions errwrap/wrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package errwrap
import (
"errors"
"fmt"
"strconv"
"testing"
)

Expand Down Expand Up @@ -46,6 +47,24 @@ func WrapfFn(msg string, args ...interface{}) func(error) error {
}
}

type errWalkTest struct {
cause error
sub []error
v int
}

func (e *errWalkTest) Error() string {
return strconv.Itoa(e.v)
}

func (e *errWalkTest) Unwrap() error {
return e.cause
}

func (e *errWalkTest) Errors() []error {
return e.sub
}

func TestWalkDeepComplexTree(t *testing.T) {
err := &errWalkTest{v: 1, cause: &errWalkTest{
sub: []error{
Expand Down Expand Up @@ -88,3 +107,9 @@ func TestWalkDeepComplexTree(t *testing.T) {
assertFind(30, "Tree node A")
assertFind(20, "Tree node with many children")
}
func testFind(err error, v int) bool {
return WalkDeep(err, func(err error) bool {
e := err.(*errWalkTest)
return e.v == v
})
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/gregwebs/errors

go 1.21
go 1.23

0 comments on commit d594a9f

Please sign in to comment.