Skip to content

Commit

Permalink
[core] Improve error condition reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
teo committed Feb 24, 2022
1 parent 80488a5 commit b6478c8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,19 @@ func (env *Environment) handleHooks(workflow workflow.Role, trigger string) (err

// If the hook call or task is critical: true
if hook.GetTraits().Critical {
log.Errorf("critical hook failed: %s", err)
log.WithField("partition", env.Id().String()).
Logf(logrus.FatalLevel, "critical hook failed: %s", err) // Must use Logf(FatalLevel) instead of
// Fatalf because the latter calls Exit
criticalFailures = append(criticalFailures, err)
} else {
log.WithField("level", infologger.IL_Devel).
WithField("partition", env.Id().String()).
Debugf("non-critical hook failed: %s", err)
}
}

if len(criticalFailures) != 0 {
return fmt.Errorf("one or more critical hooks failed")
return fmt.Errorf("%d critical hooks failed at trigger %s", len(criticalFailures), trigger)
}
return nil
}
Expand Down

0 comments on commit b6478c8

Please sign in to comment.