Skip to content

Commit 04c0010

Browse files
matteonardellimatnar
authored andcommitted
Minor: Review workflow.Invoke to handle error first
1 parent 1399c85 commit 04c0010

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

internal/workflow/workflow.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,12 @@ func (wflow *Workflow) Invoke(r *Request) error {
441441

442442
for len(progress.ReadyToExecute) > 0 {
443443
decision, err := offloadingPolicy.Evaluate(r, progress)
444-
if err == nil && decision.Offload {
445444

445+
if err != nil {
446+
return fmt.Errorf("an error occurred in policy evaluation: %v", err)
447+
}
448+
449+
if decision.Offload {
446450
err := progress.Save()
447451
if err != nil {
448452
return fmt.Errorf("Could not save progress: %v", err)
@@ -471,7 +475,7 @@ func (wflow *Workflow) Invoke(r *Request) error {
471475
return fmt.Errorf("Could not retrieve progress after offloading: %v", err)
472476
}
473477
log.Printf("Ready to execute after offloading: %v", progress.ReadyToExecute)
474-
} else if err == nil {
478+
} else {
475479
// pick next executable task
476480
var taskToExecute TaskId = ""
477481
for _, task := range progress.ReadyToExecute {
@@ -537,8 +541,6 @@ func (wflow *Workflow) Invoke(r *Request) error {
537541

538542
return nil
539543
}
540-
} else {
541-
return fmt.Errorf("an error occurred in policy evaluation: %v", err)
542544
}
543545

544546
}

0 commit comments

Comments
 (0)