Unverified Commit dd48868a authored by Silvano Cerza's avatar Silvano Cerza Committed by GitHub

board list now returns partial results in case of errors (#1668)

parent 56a2ccde
......@@ -70,7 +70,6 @@ func runListCommand(cmd *cobra.Command, args []string) {
})
if err != nil {
feedback.Errorf(tr("Error detecting boards: %v"), err)
os.Exit(errorcodes.ErrNetwork)
}
feedback.PrintResult(result{ports})
}
......
......@@ -174,7 +174,9 @@ func identify(pm *packagemanager.PackageManager, port *discovery.Port) ([]*rpc.B
return boards, nil
}
// List FIXMEDOC
// List returns a list of boards found by the loaded discoveries.
// In case of errors partial results from discoveries that didn't fail
// are returned.
func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, e error) {
tags := map[string]string{}
// Use defer func() to evaluate tags map when function returns
......@@ -208,9 +210,6 @@ func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, e error) {
retVal := []*rpc.DetectedPort{}
ports, errs := pm.DiscoveryManager().List()
if len(errs) > 0 {
return nil, &arduino.UnavailableError{Message: tr("Error getting board list"), Cause: fmt.Errorf("%v", errs)}
}
for _, port := range ports {
boards, err := identify(pm, port)
if err != nil {
......@@ -225,7 +224,9 @@ func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, e error) {
}
retVal = append(retVal, b)
}
if len(errs) > 0 {
return retVal, &arduino.UnavailableError{Message: tr("Error getting board list"), Cause: fmt.Errorf("%v", errs)}
}
return retVal, nil
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment