@@ -158,14 +158,12 @@ func (a *ArduinoPlatformUpdater) UpgradePackages(ctx context.Context, names []st
158158 srv := commands .NewArduinoCoreServer ()
159159
160160 if err := setConfig (ctx , srv ); err != nil {
161- eventCB (update .NewErrorEvent (fmt .Errorf ("error setting config: %w" , err )))
162- return nil
161+ return fmt .Errorf ("error setting config: %w" , err )
163162 }
164163
165164 var inst * rpc.Instance
166165 if resp , err := srv .Create (ctx , & rpc.CreateRequest {}); err != nil {
167- eventCB (update .NewErrorEvent (fmt .Errorf ("error creating arduino-cli instance: %w" , err )))
168- return nil
166+ return fmt .Errorf ("error creating arduino-cli instance: %w" , err )
169167 } else {
170168 inst = resp .GetInstance ()
171169 }
@@ -180,12 +178,10 @@ func (a *ArduinoPlatformUpdater) UpgradePackages(ctx context.Context, names []st
180178 {
181179 stream , _ := commands .UpdateIndexStreamResponseToCallbackFunction (ctx , downloadProgressCB )
182180 if err := srv .UpdateIndex (& rpc.UpdateIndexRequest {Instance : inst }, stream ); err != nil {
183- eventCB (update .NewErrorEvent (fmt .Errorf ("error updating index: %w" , err )))
184- return nil
181+ return fmt .Errorf ("error updating index: %w" , err )
185182 }
186183 if err := srv .Init (& rpc.InitRequest {Instance : inst }, commands .InitStreamResponseToCallbackFunction (ctx , nil )); err != nil {
187- eventCB (update .NewErrorEvent (fmt .Errorf ("error initializing instance: %w" , err )))
188- return nil
184+ return fmt .Errorf ("error initializing instance: %w" , err )
189185 }
190186 }
191187
@@ -212,8 +208,7 @@ func (a *ArduinoPlatformUpdater) UpgradePackages(ctx context.Context, names []st
212208
213209 var notFound * cmderrors.PlatformNotFoundError
214210 if ! errors .As (err , & notFound ) {
215- eventCB (update .NewErrorEvent (fmt .Errorf ("error upgrading platform: %w" , err )))
216- return nil
211+ return fmt .Errorf ("error upgrading platform: %w" , err )
217212 }
218213 // If the platform is not found, we will try to install it
219214 err := srv .PlatformInstall (
@@ -229,12 +224,10 @@ func (a *ArduinoPlatformUpdater) UpgradePackages(ctx context.Context, names []st
229224 ),
230225 )
231226 if err != nil {
232- eventCB (update .NewErrorEvent (fmt .Errorf ("error installing platform: %w" , err )))
233- return nil
227+ return fmt .Errorf ("error installing platform: %w" , err )
234228 }
235229 } else if respCB ().GetPlatform () == nil {
236- eventCB (update .NewErrorEvent (fmt .Errorf ("platform upgrade failed" )))
237- return nil
230+ return fmt .Errorf ("platform upgrade failed" )
238231 }
239232
240233 cbw := orchestrator .NewCallbackWriter (func (line string ) {
@@ -250,8 +243,7 @@ func (a *ArduinoPlatformUpdater) UpgradePackages(ctx context.Context, names []st
250243 commands .BurnBootloaderToServerStreams (ctx , cbw , cbw ),
251244 )
252245 if err != nil {
253- eventCB (update .NewErrorEvent (fmt .Errorf ("error burning bootloader: %w" , err )))
254- return nil
246+ return fmt .Errorf ("error burning bootloader: %w" , err )
255247 }
256248
257249 return nil
0 commit comments