package errors

import "github.com/influxdata/influxdb/pkg/errors"

Index

Functions

func Capture

func Capture(rErr *error, fn func() error) func()

Capture is a wrapper function which can be used to capture errors from closing via a defer. An example:

func Example() (err error) {
    f, _ := os.Open(...)
    defer errors.Capture(&err, f.Close)()
    ...
    return

Doing this will result in the error from the f.Close() call being put in the error via a ptr, if the error is not nil

Source Files

error_capture.go

Version
v1.12.0 (latest)
Published
Apr 8, 2025
Platform
linux/amd64
Last checked
2 days ago

Tools for package owners.