Skip to content

Commit f0cff2c

Browse files
committed
board list now returns partial results in case of errors
1 parent ca58aca commit f0cff2c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

cli/board/list.go

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ func runListCommand(cmd *cobra.Command, args []string) {
7070
})
7171
if err != nil {
7272
feedback.Errorf(tr("Error detecting boards: %v"), err)
73-
os.Exit(errorcodes.ErrNetwork)
7473
}
7574
feedback.PrintResult(result{ports})
7675
}

commands/board/list.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ func identify(pm *packagemanager.PackageManager, port *discovery.Port) ([]*rpc.B
174174
return boards, nil
175175
}
176176

177-
// List FIXMEDOC
177+
// List returns a list of boards found by the loaded discoveries.
178+
// In case of errors partial results from discoveries that didn't fail
179+
// are returned.
178180
func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, e error) {
179181
tags := map[string]string{}
180182
// Use defer func() to evaluate tags map when function returns
@@ -208,9 +210,6 @@ func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, e error) {
208210

209211
retVal := []*rpc.DetectedPort{}
210212
ports, errs := pm.DiscoveryManager().List()
211-
if len(errs) > 0 {
212-
return nil, &arduino.UnavailableError{Message: tr("Error getting board list"), Cause: fmt.Errorf("%v", errs)}
213-
}
214213
for _, port := range ports {
215214
boards, err := identify(pm, port)
216215
if err != nil {
@@ -225,7 +224,9 @@ func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, e error) {
225224
}
226225
retVal = append(retVal, b)
227226
}
228-
227+
if len(errs) > 0 {
228+
return retVal, &arduino.UnavailableError{Message: tr("Error getting board list"), Cause: fmt.Errorf("%v", errs)}
229+
}
229230
return retVal, nil
230231
}
231232

0 commit comments

Comments
 (0)