Skip to content
Merged
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
7 changes: 1 addition & 6 deletions instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,16 @@ func defaultFormatter(err error) string {
// ExecInstrument2 is a generic wrapper around Instrument.Exec that handles functions
// returning both a value and an error. This is a convenience function for instrumenting
// operations that return results.
//
// Note: The error from the instrumented function is tracked but not returned by this
// function. Use Instrument.Exec directly if you need to handle the error.
func ExecInstrument2[T any](i Instrument, fn func() (T, error)) (T, error) {
var res T

i.Exec(func() error {
return res, i.Exec(func() error {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
error returned from interface method should be wrapped: sig: func (github.com/upfluence/stats.Instrument).Exec(func() error) error (wrapcheck)

var err error

res, err = fn()

return err
})

return res, nil
}

type noopInstrument struct{}
Expand Down
Loading