@@ -20,11 +20,9 @@ package core
20
20
import (
21
21
"context"
22
22
"fmt"
23
- "os"
24
23
25
24
"github.com/arduino/arduino-cli/arduino/cores"
26
25
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
27
- "github.com/arduino/arduino-cli/cli"
28
26
"github.com/arduino/arduino-cli/commands"
29
27
"github.com/arduino/arduino-cli/common/formatter"
30
28
"github.com/arduino/arduino-cli/rpc"
@@ -36,7 +34,7 @@ func PlatformUninstall(ctx context.Context, req *rpc.PlatformUninstallReq) (*rpc
36
34
version , err := semver .Parse (req .Version )
37
35
if err != nil {
38
36
formatter .PrintError (err , "version not readable" )
39
-
37
+ return fmt . Errorf ( "version not readable" , err )
40
38
}
41
39
ref := & packagemanager.PlatformReference {
42
40
Package : req .PlatformPackage ,
@@ -47,11 +45,13 @@ func PlatformUninstall(ctx context.Context, req *rpc.PlatformUninstallReq) (*rpc
47
45
platform := pm .FindPlatform (ref )
48
46
if platform == nil {
49
47
formatter .PrintErrorMessage ("Platform not found " + ref .String ())
48
+ return fmt .Errorf ("Platform not found " + ref .String (), err )
50
49
51
50
}
52
51
platformRelease := pm .GetInstalledPlatformRelease (platform )
53
52
if platformRelease == nil {
54
53
formatter .PrintErrorMessage ("Platform not installed " + ref .String ())
54
+ return fmt .Errorf ("Platform not installed " + ref .String (), err )
55
55
56
56
}
57
57
ref .PlatformVersion = platformRelease .Version
@@ -60,6 +60,7 @@ func PlatformUninstall(ctx context.Context, req *rpc.PlatformUninstallReq) (*rpc
60
60
platform , tools , err := pm .FindPlatformReleaseDependencies (ref )
61
61
if err != nil {
62
62
formatter .PrintError (err , "Could not determine platform dependencies" )
63
+ return fmt .Errorf ("Could not determine platform dependencies" , err )
63
64
64
65
}
65
66
@@ -83,7 +84,7 @@ func uninstallPlatformRelease(pm *packagemanager.PackageManager, platformRelease
83
84
if err := pm .UninstallPlatform (platformRelease ); err != nil {
84
85
log .WithError (err ).Error ("Error uninstalling" )
85
86
formatter .PrintError (err , "Error uninstalling " + platformRelease .String ())
86
- os . Exit ( cli . ErrGeneric )
87
+ return fmt . Errorf ( "Error uninstalling " + platformRelease . String (), err )
87
88
}
88
89
89
90
log .Info ("Platform uninstalled" )
@@ -99,7 +100,7 @@ func uninstallToolRelease(pm *packagemanager.PackageManager, toolRelease *cores.
99
100
if err := pm .UninstallTool (toolRelease ); err != nil {
100
101
log .WithError (err ).Error ("Error uninstalling" )
101
102
formatter .PrintError (err , "Error uninstalling " + toolRelease .String ())
102
- os . Exit ( cli . ErrGeneric )
103
+ return fmt . Errorf ( "Error uninstalling " + toolRelease . String (), err )
103
104
}
104
105
105
106
log .Info ("Tool uninstalled" )
0 commit comments