@@ -17,7 +17,6 @@ package instance
17
17
18
18
import (
19
19
"context"
20
- "errors"
21
20
"os"
22
21
23
22
"github.com/arduino/arduino-cli/cli/errorcodes"
@@ -50,10 +49,7 @@ func CreateAndInitWithProfile(profileName string, sketchPath *paths.Path) (*rpc.
50
49
feedback .Errorf (tr ("Error creating instance: %v" ), err )
51
50
os .Exit (errorcodes .ErrGeneric )
52
51
}
53
- profile , errs := InitWithProfile (instance , profileName , sketchPath )
54
- for _ , err := range errs {
55
- feedback .Errorf (tr ("Error initializing instance: %v" ), err )
56
- }
52
+ profile := InitWithProfile (instance , profileName , sketchPath )
57
53
return instance , profile
58
54
}
59
55
@@ -71,20 +67,18 @@ func Create() (*rpc.Instance, error) {
71
67
// platform or library that we failed to load.
72
68
// Package and library indexes files are automatically updated if the
73
69
// CLI is run for the first time.
74
- func Init (instance * rpc.Instance ) []error {
75
- _ , errs := InitWithProfile (instance , "" , nil )
76
- return errs
70
+ func Init (instance * rpc.Instance ) {
71
+ InitWithProfile (instance , "" , nil )
77
72
}
78
73
79
74
// InitWithProfile initializes instance by loading libraries and platforms specified in the given profile of the given sketch.
80
75
// In case of loading failures return a list of errors for each platform or library that we failed to load.
81
76
// Required Package and library indexes files are automatically downloaded.
82
- func InitWithProfile (instance * rpc.Instance , profileName string , sketchPath * paths.Path ) (* rpc.Profile , []error ) {
83
- errs := []error {}
84
-
77
+ func InitWithProfile (instance * rpc.Instance , profileName string , sketchPath * paths.Path ) * rpc.Profile {
85
78
// In case the CLI is executed for the first time
86
79
if err := FirstUpdate (instance ); err != nil {
87
- return nil , append (errs , err )
80
+ feedback .Errorf (tr ("Error initializing instance: %v" ), err )
81
+ return nil
88
82
}
89
83
90
84
downloadCallback := output .ProgressBar ()
@@ -98,7 +92,7 @@ func InitWithProfile(instance *rpc.Instance, profileName string, sketchPath *pat
98
92
var profile * rpc.Profile
99
93
err := commands .Init (initReq , func (res * rpc.InitResponse ) {
100
94
if st := res .GetError (); st != nil {
101
- errs = append ( errs , errors . New ( st .Message ) )
95
+ feedback . Errorf ( tr ( "Error initializing instance: %v" ), st .Message )
102
96
}
103
97
104
98
if progress := res .GetInitProgress (); progress != nil {
@@ -115,10 +109,10 @@ func InitWithProfile(instance *rpc.Instance, profileName string, sketchPath *pat
115
109
}
116
110
})
117
111
if err != nil {
118
- errs = append ( errs , err )
112
+ feedback . Errorf ( tr ( "Error initializing instance: %v" ) , err )
119
113
}
120
114
121
- return profile , errs
115
+ return profile
122
116
}
123
117
124
118
// FirstUpdate downloads libraries and packages indexes if they don't exist.
0 commit comments