@@ -17,7 +17,6 @@ package instance
1717
1818import (
1919 "context"
20- "errors"
2120 "os"
2221
2322 "github.com/arduino/arduino-cli/cli/errorcodes"
@@ -50,10 +49,7 @@ func CreateAndInitWithProfile(profileName string, sketchPath *paths.Path) (*rpc.
5049 feedback .Errorf (tr ("Error creating instance: %v" ), err )
5150 os .Exit (errorcodes .ErrGeneric )
5251 }
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 )
5753 return instance , profile
5854}
5955
@@ -71,20 +67,18 @@ func Create() (*rpc.Instance, error) {
7167// platform or library that we failed to load.
7268// Package and library indexes files are automatically updated if the
7369// 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 )
7772}
7873
7974// InitWithProfile initializes instance by loading libraries and platforms specified in the given profile of the given sketch.
8075// In case of loading failures return a list of errors for each platform or library that we failed to load.
8176// 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 {
8578 // In case the CLI is executed for the first time
8679 if err := FirstUpdate (instance ); err != nil {
87- return nil , append (errs , err )
80+ feedback .Errorf (tr ("Error initializing instance: %v" ), err )
81+ return nil
8882 }
8983
9084 downloadCallback := output .ProgressBar ()
@@ -98,7 +92,7 @@ func InitWithProfile(instance *rpc.Instance, profileName string, sketchPath *pat
9892 var profile * rpc.Profile
9993 err := commands .Init (initReq , func (res * rpc.InitResponse ) {
10094 if st := res .GetError (); st != nil {
101- errs = append ( errs , errors . New ( st .Message ) )
95+ feedback . Errorf ( tr ( "Error initializing instance: %v" ), st .Message )
10296 }
10397
10498 if progress := res .GetInitProgress (); progress != nil {
@@ -115,10 +109,10 @@ func InitWithProfile(instance *rpc.Instance, profileName string, sketchPath *pat
115109 }
116110 })
117111 if err != nil {
118- errs = append ( errs , err )
112+ feedback . Errorf ( tr ( "Error initializing instance: %v" ) , err )
119113 }
120114
121- return profile , errs
115+ return profile
122116}
123117
124118// FirstUpdate downloads libraries and packages indexes if they don't exist.
0 commit comments