A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/arduino/arduino-cli/commit/11b2625fc8b4af5ce10a183886d682ddf1e5cdfc below:

Improve error code when platform not available for OS (#2933) · arduino/arduino-cli@11b2625 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+28

-1

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+28

-1

lines changed Original file line number Diff line number Diff line change

@@ -16,6 +16,7 @@

16 16

package cmderrors

17 17 18 18

import (

19 +

"errors"

19 20

"fmt"

20 21

"strings"

21 22

@@ -415,6 +416,26 @@ func (e *PlatformNotFoundError) Unwrap() error {

415 416

return e.Cause

416 417

}

417 418 419 +

// PlatformNotAvailableForOSError is returned when a platform contains a tool not available

420 +

// for the user OS + ARCH

421 +

type PlatformNotAvailableForOSError struct {

422 +

Platform string

423 +

Cause error

424 +

}

425 + 426 +

func (e *PlatformNotAvailableForOSError) Error() string {

427 +

return composeErrorMsg(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 +

return status.New(codes.FailedPrecondition, e.Error())

433 +

}

434 + 435 +

func (e *PlatformNotAvailableForOSError) Unwrap() error {

436 +

return e.Cause

437 +

}

438 + 418 439

// PlatformLoadingError is returned when a platform has fatal errors that prevents loading

419 440

type PlatformLoadingError struct {

420 441

Cause error

Original file line number Diff line number Diff line change

@@ -17,6 +17,7 @@ package commands

17 17 18 18

import (

19 19

"context"

20 +

"errors"

20 21

"fmt"

21 22 22 23

"github.com/arduino/arduino-cli/commands/cmderrors"

@@ -79,6 +80,9 @@ func (s *arduinoCoreServerImpl) PlatformInstall(req *rpc.PlatformInstallRequest,

79 80

}

80 81

platformRelease, tools, err := pme.FindPlatformReleaseDependencies(ref)

81 82

if err != nil {

83 +

if errors.Is(err, packagemanager.ErrPlatformNotAvailableForOS) {

84 +

return &cmderrors.PlatformNotAvailableForOSError{Platform: ref.String()}

85 +

}

82 86

return &cmderrors.PlatformNotFoundError{Platform: ref.String(), Cause: err}

83 87

}

84 88 Original file line number Diff line number Diff line change

@@ -26,6 +26,8 @@ import (

26 26

semver "go.bug.st/relaxed-semver"

27 27

)

28 28 29 +

var ErrPlatformNotAvailableForOS = errors.New("platform is not available for your OS")

30 + 29 31

// PlatformReference represents a tuple to identify a Platform

30 32

type PlatformReference struct {

31 33

Package string // The package where this Platform belongs to.

@@ -89,7 +91,7 @@ func (pme *Explorer) FindPlatformReleaseDependencies(item *PlatformReference) (*

89 91

} else {

90 92

release = platform.GetLatestCompatibleRelease()

91 93

if release == nil {

92 -

return nil, nil, errors.New(i18n.Tr("platform is not available for your OS"))

94 +

return nil, nil, ErrPlatformNotAvailableForOS

93 95

}

94 96

}

95 97

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4