Skip to content

Commit 22113fe

Browse files
committed
Added return to uninstall command
1 parent fd5334c commit 22113fe

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

commands/core/uninstall.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ package core
2020
import (
2121
"context"
2222
"fmt"
23-
"os"
2423

2524
"github.com/arduino/arduino-cli/arduino/cores"
2625
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
27-
"github.com/arduino/arduino-cli/cli"
2826
"github.com/arduino/arduino-cli/commands"
2927
"github.com/arduino/arduino-cli/common/formatter"
3028
"github.com/arduino/arduino-cli/rpc"
@@ -36,7 +34,7 @@ func PlatformUninstall(ctx context.Context, req *rpc.PlatformUninstallReq) (*rpc
3634
version, err := semver.Parse(req.Version)
3735
if err != nil {
3836
formatter.PrintError(err, "version not readable")
39-
37+
return fmt.Errorf("version not readable", err)
4038
}
4139
ref := &packagemanager.PlatformReference{
4240
Package: req.PlatformPackage,
@@ -47,11 +45,13 @@ func PlatformUninstall(ctx context.Context, req *rpc.PlatformUninstallReq) (*rpc
4745
platform := pm.FindPlatform(ref)
4846
if platform == nil {
4947
formatter.PrintErrorMessage("Platform not found " + ref.String())
48+
return fmt.Errorf("Platform not found "+ref.String(), err)
5049

5150
}
5251
platformRelease := pm.GetInstalledPlatformRelease(platform)
5352
if platformRelease == nil {
5453
formatter.PrintErrorMessage("Platform not installed " + ref.String())
54+
return fmt.Errorf("Platform not installed "+ref.String(), err)
5555

5656
}
5757
ref.PlatformVersion = platformRelease.Version
@@ -60,6 +60,7 @@ func PlatformUninstall(ctx context.Context, req *rpc.PlatformUninstallReq) (*rpc
6060
platform, tools, err := pm.FindPlatformReleaseDependencies(ref)
6161
if err != nil {
6262
formatter.PrintError(err, "Could not determine platform dependencies")
63+
return fmt.Errorf("Could not determine platform dependencies", err)
6364

6465
}
6566

@@ -83,7 +84,7 @@ func uninstallPlatformRelease(pm *packagemanager.PackageManager, platformRelease
8384
if err := pm.UninstallPlatform(platformRelease); err != nil {
8485
log.WithError(err).Error("Error uninstalling")
8586
formatter.PrintError(err, "Error uninstalling "+platformRelease.String())
86-
os.Exit(cli.ErrGeneric)
87+
return fmt.Errorf("Error uninstalling "+platformRelease.String(), err)
8788
}
8889

8990
log.Info("Platform uninstalled")
@@ -99,7 +100,7 @@ func uninstallToolRelease(pm *packagemanager.PackageManager, toolRelease *cores.
99100
if err := pm.UninstallTool(toolRelease); err != nil {
100101
log.WithError(err).Error("Error uninstalling")
101102
formatter.PrintError(err, "Error uninstalling "+toolRelease.String())
102-
os.Exit(cli.ErrGeneric)
103+
return fmt.Errorf("Error uninstalling "+toolRelease.String(), err)
103104
}
104105

105106
log.Info("Tool uninstalled")

0 commit comments

Comments
 (0)