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