Commit d684dec1 authored by Silvano Cerza's avatar Silvano Cerza Committed by Silvano Cerza

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

parent 10107d24
...@@ -70,7 +70,6 @@ func runListCommand(cmd *cobra.Command, args []string) { ...@@ -70,7 +70,6 @@ func runListCommand(cmd *cobra.Command, args []string) {
}) })
if err != nil { if err != nil {
feedback.Errorf(tr("Error detecting boards: %v"), err) feedback.Errorf(tr("Error detecting boards: %v"), err)
os.Exit(errorcodes.ErrNetwork)
} }
feedback.PrintResult(result{ports}) feedback.PrintResult(result{ports})
} }
......
...@@ -174,7 +174,9 @@ func identify(pm *packagemanager.PackageManager, port *discovery.Port) ([]*rpc.B ...@@ -174,7 +174,9 @@ func identify(pm *packagemanager.PackageManager, port *discovery.Port) ([]*rpc.B
return boards, nil 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) { func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, e error) {
tags := map[string]string{} tags := map[string]string{}
// Use defer func() to evaluate tags map when function returns // Use defer func() to evaluate tags map when function returns
...@@ -208,9 +210,6 @@ func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, e error) { ...@@ -208,9 +210,6 @@ func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, e error) {
retVal := []*rpc.DetectedPort{} retVal := []*rpc.DetectedPort{}
ports, errs := pm.DiscoveryManager().List() 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 { for _, port := range ports {
boards, err := identify(pm, port) boards, err := identify(pm, port)
if err != nil { if err != nil {
...@@ -225,7 +224,9 @@ func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, e error) { ...@@ -225,7 +224,9 @@ func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, e error) {
} }
retVal = append(retVal, b) 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 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