Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cli/board/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}
Expand Down
11 changes: 6 additions & 5 deletions commands/board/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down