Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cf5db1b

Browse files
authored
Fixed weird error message in core install if invalid platform is spcified (#2309)
* Fixed weird error message in 'core install' if invalid platform is specified * Fixed integration test
1 parent 5e01a2e commit cf5db1b

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

‎arduino/errors.go‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -837,11 +837,8 @@ type MultiplePlatformsError struct {
837837
}
838838

839839
func (e *MultiplePlatformsError) Error() string {
840-
return tr("Found %d platform for reference \"%s\":\n%s",
841-
len(e.Platforms),
842-
e.UserPlatform,
843-
strings.Join(e.Platforms, "\n"),
844-
)
840+
return tr("Found %d platforms matching \"%s\": %s",
841+
len(e.Platforms), e.UserPlatform, strings.Join(e.Platforms, ", "))
845842
}
846843

847844
// ToRPCStatus converts the error into a *status.Status

‎internal/cli/arguments/reference.go‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,13 @@ func ParseReference(arg string) (*Reference, error) {
116116
}
117117
// replace the returned Reference only if only one occurrence is found,
118118
// otherwise return an error to the user because we don't know on which platform operate
119-
if len(foundPlatforms) == 1 {
120-
ret.PackageName=toks[0]
121-
ret.Architecture=toks[1]
122-
} else {
119+
if len(foundPlatforms) == 0 {
120+
returnnil, &arduino.PlatformNotFoundError{Platform: arg}
121+
}
122+
iflen(foundPlatforms) >1 {
123123
return nil, &arduino.MultiplePlatformsError{Platforms: foundPlatforms, UserPlatform: arg}
124124
}
125+
ret.PackageName = toks[0]
126+
ret.Architecture = toks[1]
125127
return ret, nil
126128
}

‎internal/integrationtest/core/core_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ func TestCoreDownloadMultiplePlatforms(t *testing.T) {
883883
// The cli should not allow it since optimizing the casing results in finding two cores
884884
_, stderr, err := cli.Run("core", "upgrade", "Packager:Arch")
885885
require.Error(t, err)
886-
require.Contains(t, string(stderr), "Invalid argument passed: Found 2 platform for reference")
886+
require.Contains(t, string(stderr), "Invalid argument passed: Found 2 platforms matching")
887887
}
888888

889889
func TestCoreWithMissingCustomBoardOptionsIsLoaded(t *testing.T) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /