Skip to content

Commit

Permalink
Merge pull request #17441 from fuweid/using-retErr
Browse files Browse the repository at this point in the history
server/verify: use retErr to shadow local err
  • Loading branch information
ahrtr authored Feb 17, 2024
2 parents e0cb943 + 0354d39 commit 7d640a5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions server/verify/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type Config struct {
// the function can also panic.
// The function is expected to work on not-in-use data model, i.e.
// no file-locks should be taken. Verify does not modified the data.
func Verify(cfg Config) error {
func Verify(cfg Config) (retErr error) {
lg := cfg.Logger
if lg == nil {
lg = zap.NewNop()
Expand All @@ -59,13 +59,12 @@ func Verify(cfg Config) error {
return nil
}

var err error
lg.Info("verification of persisted state", zap.String("data-dir", cfg.DataDir))
defer func() {
if err != nil {
if retErr != nil {
lg.Error("verification of persisted state failed",
zap.String("data-dir", cfg.DataDir),
zap.Error(err))
zap.Error(retErr))
} else if r := recover(); r != nil {
lg.Error("verification of persisted state failed",
zap.String("data-dir", cfg.DataDir))
Expand Down

0 comments on commit 7d640a5

Please sign in to comment.