Skip to content

Commit 6a17436

Browse files
committed
fix: update error handling in ValidateBricks to yield all validation errors instead of the first one
1 parent d8028b6 commit 6a17436

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

internal/orchestrator/app/parser.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ import (
2121
"io"
2222

2323
emoji "github.com/Andrew-M-C/go.emoji"
24-
"github.com/arduino/arduino-app-cli/internal/orchestrator/bricksindex"
2524
"github.com/arduino/go-paths-helper"
2625
"github.com/goccy/go-yaml"
2726
"github.com/goccy/go-yaml/ast"
27+
28+
"github.com/arduino/arduino-app-cli/internal/orchestrator/bricksindex"
2829
)
2930

3031
type Brick struct {

internal/orchestrator/orchestrator.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,13 @@ func StartApp(
122122
ctx, cancel := context.WithCancel(ctx)
123123
defer cancel()
124124

125-
err := app.Descriptor.ValidateBricks(bricksIndex)
126-
if err != nil {
127-
yield(StreamMessage{error: err})
125+
errs := app.Descriptor.ValidateBricks(bricksIndex)
126+
if errs != nil {
127+
for _, e := range errs {
128+
if !yield(StreamMessage{error: e}) {
129+
return
130+
}
131+
}
128132
return
129133
}
130134

@@ -453,9 +457,13 @@ func RestartApp(
453457
ctx, cancel := context.WithCancel(ctx)
454458
defer cancel()
455459

456-
err := appToStart.Descriptor.ValidateBricks(bricksIndex)
457-
if err != nil {
458-
yield(StreamMessage{error: err})
460+
errs := appToStart.Descriptor.ValidateBricks(bricksIndex)
461+
if errs != nil {
462+
for _, e := range errs {
463+
if !yield(StreamMessage{error: e}) {
464+
return
465+
}
466+
}
459467
return
460468
}
461469

0 commit comments

Comments
 (0)