Skip to content
Snippets Groups Projects
Unverified Commit cdafd42f authored by dlorenc's avatar dlorenc Committed by GitHub
Browse files

Merge pull request #20 from lukehinds/file-hand

Capture case of no previous state file present
parents 4178382e 231111d9
No related branches found
No related tags found
No related merge requests found
...@@ -74,10 +74,18 @@ func getPreviousState(log *zap.SugaredLogger) *state { ...@@ -74,10 +74,18 @@ func getPreviousState(log *zap.SugaredLogger) *state {
} }
var oldState state var oldState state
f, err := ioutil.ReadFile(p) f, err := ioutil.ReadFile(p)
if err != nil { if err != nil {
log.Info(err) if os.IsNotExist(err) {
return nil log.Info("No previous state found at: ", p)
return nil
} else {
// Capture any other errors
log.Error(err)
return nil
}
} }
if err := json.Unmarshal(f, &oldState); err != nil { if err := json.Unmarshal(f, &oldState); err != nil {
log.Info(err) log.Info(err)
return nil return nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment