[runsc] Print file name when cannot load state file

This commit is contained in:
Stepan Koltsov
2025-02-10 17:52:55 +00:00
parent 9c490f813d
commit f0ac6d5c9f
+5 -1
View File
@@ -383,8 +383,12 @@ func (s *StateFile) load(v any, opts LoadOpts) error {
}
defer s.UnlockOrDie()
metaBytes, err := os.ReadFile(s.statePath())
path := s.statePath()
metaBytes, err := os.ReadFile(path)
if err != nil {
// Caller of this function relies on error code, we cannot return new error,
// but we need to provide a message with file name.
log.Warningf("Error loading state file %q: %v", path, err)
return err
}
return json.Unmarshal(metaBytes, &v)