You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, this could be because wrapper is not initialized like here
However, i was looking into %w from the go blog and feel %w here is used incorrectly. Please correct me if i am wrong.
Wrapping errors with %w
As mentioned earlier, it is common to use the fmt.Errorf function to add additional information to an error.
if err != nil {
return fmt.Errorf("decompress %v: %v", name, err)
}
In Go 1.13, the fmt.Errorf function supports a new %w verb. When this verb is present, the error returned by fmt.Errorf will have an Unwrap method returning the argument of %w, which must be an error. In all other ways, %w is identical to %v.
if err != nil {
// Return an error which unwraps to err.
return fmt.Errorf("decompress %v: %w", name, err)
}
Wrapping an error with %w makes it available to errors.Is and errors.As:
Description
We're seeing some errors which I believe are coming from opentelemetry-go with the prefix
%!w(<nil>):
.Environment
Steps To Reproduce
This appears to be the culprit:
opentelemetry-go/sdk/metric/pipeline.go
Line 507 in d5fca83
opentelemetry-go/sdk/metric/pipeline.go
Line 527 in d5fca83
Expected behavior
We shouldn't wrap errors if the error is nil. To fix, I think we should either:
m.wrapped
if nil when callingfunc (m *multierror) append(err error)
.errorOrNil()
to remove the prefix%w:
if wrapped is not set.The text was updated successfully, but these errors were encountered: