Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display messages on all close errors in workunitbase #1192

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions pkg/workceptor/workunitbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@
}
err = sfd.saveToFile(file)
if err != nil {
_ = file.Close()
serr := file.Close()

if serr != nil {
MainInstance.nc.GetLogger().Error("Error closing %s: %s", filename, serr)
}

Check warning on line 230 in pkg/workceptor/workunitbase.go

View check run for this annotation

Codecov / codecov/patch

pkg/workceptor/workunitbase.go#L226-L230

Added lines #L226 - L230 were not covered by tests

return err
}
Expand Down Expand Up @@ -262,7 +266,10 @@
}
err = sfd.loadFromFile(file)
if err != nil {
_ = file.Close()
lerr := file.Close()
if lerr != nil {
MainInstance.nc.GetLogger().Error("Error closing %s: %s", filename, lerr)
}

Check warning on line 272 in pkg/workceptor/workunitbase.go

View check run for this annotation

Codecov / codecov/patch

pkg/workceptor/workunitbase.go#L269-L272

Added lines #L269 - L272 were not covered by tests

return err
}
Expand Down Expand Up @@ -389,11 +396,17 @@
err := bwu.watcher.Add(statusFile)
if err == nil {
defer func() {
_ = bwu.watcher.Close()
werr := bwu.watcher.Close()
if werr != nil {
bwu.w.nc.GetLogger().Error("Error closing %s: %s", statusFile, err)
}

Check warning on line 402 in pkg/workceptor/workunitbase.go

View check run for this annotation

Codecov / codecov/patch

pkg/workceptor/workunitbase.go#L401-L402

Added lines #L401 - L402 were not covered by tests
}()
watcherEvents = bwu.watcher.EventChannel()
} else {
_ = bwu.watcher.Close()
werr := bwu.watcher.Close()
if werr != nil {
bwu.w.nc.GetLogger().Error("Error closing %s: %s", statusFile, err)
}

Check warning on line 409 in pkg/workceptor/workunitbase.go

View check run for this annotation

Codecov / codecov/patch

pkg/workceptor/workunitbase.go#L408-L409

Added lines #L408 - L409 were not covered by tests
bwu.watcher = nil
}
}
Expand Down