Skip to content

Commit

Permalink
upgrade to new ErrorWrap definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Weber committed Oct 31, 2024
1 parent 1845cce commit 1e38bb1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions codes.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func NewCodedError(err error, code Code) CodedError {
}
return CodedError{
GetCode: code,
ErrorWrap: &errors.ErrorWrap{Err: err},
ErrorWrap: errors.NewErrorWrap(err),
}
}

Expand Down Expand Up @@ -170,7 +170,7 @@ func makeInternalStackCode(defaultCode Code) func(error) StackCode {
}
return NewStackCode(CodedError{
GetCode: code,
ErrorWrap: &errors.ErrorWrap{Err: err},
ErrorWrap: errors.NewErrorWrap(err),
}, 3)
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/gregwebs/errcode

go 1.21.9

require github.com/gregwebs/errors v1.13.3
require github.com/gregwebs/errors v1.16.0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/gregwebs/errors v1.13.3 h1:8hfIWNIU8EgCN98nzXwS690AKKRsGq2nih3PdbhWh9s=
github.com/gregwebs/errors v1.13.3/go.mod h1:1NkCObP7+scylHlC69lwHl2ACOHwktWYrZV4EJDEl6g=
github.com/gregwebs/errors v1.16.0 h1:7dlwrZAfPW3WSDEoXJ95x95QBtRqDNmJp2tZ/Xd9PcI=
github.com/gregwebs/errors v1.16.0/go.mod h1:1NkCObP7+scylHlC69lwHl2ACOHwktWYrZV4EJDEl6g=
8 changes: 4 additions & 4 deletions stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ func NewStackCode(err ErrorCode, position ...int) StackCode {
if err == nil {
panic("NewStackCode: given error is nil")
}
stackPosition := 1
if len(position) > 0 {
stackPosition = position[0]
}

// if there is an existing trace, take that: it should be deeper
if tracer := errors.GetStackTracer(err); tracer != nil {
return StackCode{ErrorCode: err, GetStack: tracer}
}

stackPosition := 1
if len(position) > 0 {
stackPosition = position[0]
}
return StackCode{ErrorCode: err, GetStack: errors.NewStack(stackPosition)}
}

Expand Down
2 changes: 1 addition & 1 deletion wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ type withError[T any] struct {
func newWithError[Err error](errCode Err, wrapErr func(error) error) withError[Err] {
return withError[Err]{
With: errCode,
ErrorWrap: &errors.ErrorWrap{Err: wrapErr(errCode)},
ErrorWrap: errors.NewErrorWrap(wrapErr(errCode)),
}
}

Expand Down

0 comments on commit 1e38bb1

Please sign in to comment.