Movatterモバイル変換


[0]ホーム

URL:


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

Commit11b2625

Browse files
Improve error code when platform not available for OS (#2933)
* arduino: improve error code when platform not available for OS* fix typo
1 parent2947cfb commit11b2625

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

‎commands/cmderrors/cmderrors.go‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package cmderrors
1717

1818
import (
19+
"errors"
1920
"fmt"
2021
"strings"
2122

@@ -415,6 +416,26 @@ func (e *PlatformNotFoundError) Unwrap() error {
415416
returne.Cause
416417
}
417418

419+
// PlatformNotAvailableForOSError is returned when a platform contains a tool not available
420+
// for the user OS + ARCH
421+
typePlatformNotAvailableForOSErrorstruct {
422+
Platformstring
423+
Causeerror
424+
}
425+
426+
func (e*PlatformNotAvailableForOSError)Error()string {
427+
returncomposeErrorMsg(i18n.Tr("Platform '%s'",e.Platform),errors.New(i18n.Tr("platform is not available for your OS")))
428+
}
429+
430+
// GRPCStatus converts the error into a *status.Status
431+
func (e*PlatformNotAvailableForOSError)GRPCStatus()*status.Status {
432+
returnstatus.New(codes.FailedPrecondition,e.Error())
433+
}
434+
435+
func (e*PlatformNotAvailableForOSError)Unwrap()error {
436+
returne.Cause
437+
}
438+
418439
// PlatformLoadingError is returned when a platform has fatal errors that prevents loading
419440
typePlatformLoadingErrorstruct {
420441
Causeerror

‎commands/service_platform_install.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package commands
1717

1818
import (
1919
"context"
20+
"errors"
2021
"fmt"
2122

2223
"github.com/arduino/arduino-cli/commands/cmderrors"
@@ -79,6 +80,9 @@ func (s *arduinoCoreServerImpl) PlatformInstall(req *rpc.PlatformInstallRequest,
7980
}
8081
platformRelease,tools,err:=pme.FindPlatformReleaseDependencies(ref)
8182
iferr!=nil {
83+
iferrors.Is(err,packagemanager.ErrPlatformNotAvailableForOS) {
84+
return&cmderrors.PlatformNotAvailableForOSError{Platform:ref.String()}
85+
}
8286
return&cmderrors.PlatformNotFoundError{Platform:ref.String(),Cause:err}
8387
}
8488

‎internal/arduino/cores/packagemanager/download.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import (
2626
semver"go.bug.st/relaxed-semver"
2727
)
2828

29+
varErrPlatformNotAvailableForOS=errors.New("platform is not available for your OS")
30+
2931
// PlatformReference represents a tuple to identify a Platform
3032
typePlatformReferencestruct {
3133
Packagestring// The package where this Platform belongs to.
@@ -89,7 +91,7 @@ func (pme *Explorer) FindPlatformReleaseDependencies(item *PlatformReference) (*
8991
}else {
9092
release=platform.GetLatestCompatibleRelease()
9193
ifrelease==nil {
92-
returnnil,nil,errors.New(i18n.Tr("platform is not available for your OS"))
94+
returnnil,nil,ErrPlatformNotAvailableForOS
9395
}
9496
}
9597

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp