MCPcopy
hub / github.com/grafana/dskit / CloseWithErrCapture

Function CloseWithErrCapture

runutil/runutil.go:22–29  ·  view source on GitHub ↗

CloseWithErrCapture closes closer and wraps any error with the provided message and assigns it to err.

(err *error, closer io.Closer, format string, a ...interface{})

Source from the content-addressed store, hash-verified

20
21// CloseWithErrCapture closes closer and wraps any error with the provided message and assigns it to err.
22func CloseWithErrCapture(err *error, closer io.Closer, format string, a ...interface{}) {
23 merr := multierror.MultiError{}
24
25 merr.Add(*err)
26 merr.Add(errors.Wrapf(closer.Close(), format, a...))
27
28 *err = merr.Err()
29}
30
31// CloseWithLogOnErr closes an io.Closer and logs any relevant error from it wrapped with the provided format string and
32// args.

Callers 3

writeExclusivePEMFileFunction · 0.92
TestCloseWithErrCaptureFunction · 0.85

Calls 3

AddMethod · 0.95
ErrMethod · 0.95
CloseMethod · 0.65

Tested by 1

TestCloseWithErrCaptureFunction · 0.68