Skip to content

Commit

Permalink
PR FIXUP - Remove newError
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSisley committed Dec 20, 2022
1 parent f35f269 commit bf3d13d
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewKV(key string, value any) KV {
// generated.
//go:noinline
func New(message string, keyvals ...KV) error {
return newError(message, 1, keyvals...)
return withStackTrace(message, 1, keyvals...)
}

// Wrap creates a new error of the given message that contains
Expand All @@ -51,7 +51,7 @@ func New(message string, keyvals ...KV) error {
// generated.
//go:noinline
func Wrap(message string, inner error, keyvals ...KV) error {
err := newError(message, 1, keyvals...)
err := withStackTrace(message, 1, keyvals...)
err.inner = inner
return err
}
Expand All @@ -67,13 +67,6 @@ func WithStack(err error, keyvals ...KV) error {
return withStackTrace(err.Error(), 1, keyvals...)
}

// This function will not be inlined by the compiler as it will spoil any stacktrace
// generated.
//go:noinline
func newError(message string, depthToSkip int, keyvals ...KV) *defraError {
return withStackTrace(message, depthToSkip+1, keyvals...)
}

// withStackTrace creates a `defraError` with a stacktrace and the given key-value pairs.
//
// The stacktrace will skip the top `depthToSkip` frames, allowing frames/calls generated from
Expand Down

0 comments on commit bf3d13d

Please sign in to comment.