blob: 6e84549db17546ad3d94d642800293b18d422cdc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
package common
import (
"context"
log "github.com/authzed/spicedb/internal/logging"
)
// LogOnError executes the function and logs the error.
// Useful to avoid silently ignoring errors in defer statements
func LogOnError(ctx context.Context, f func() error) {
if err := f(); err != nil {
log.Ctx(ctx).Err(err).Msg("datastore error")
}
}
|