@@ -6,13 +6,20 @@ import { MessageService } from '@theia/core/lib/common/message-service';
6
6
import { ConfirmDialog } from '@theia/core/lib/browser/dialogs' ;
7
7
import { Searchable } from '../../../common/protocol/searchable' ;
8
8
import { ExecuteWithProgress } from '../../../common/protocol/progressible' ;
9
- import { Installable } from '../../../common/protocol/installable' ;
9
+ import {
10
+ Installable ,
11
+ libraryInstallFailed ,
12
+ platformInstallFailed ,
13
+ } from '../../../common/protocol/installable' ;
10
14
import { ArduinoComponent } from '../../../common/protocol/arduino-component' ;
11
15
import { SearchBar } from './search-bar' ;
12
16
import { ListWidget } from './list-widget' ;
13
17
import { ComponentList } from './component-list' ;
14
18
import { ListItemRenderer } from './list-item-renderer' ;
15
- import { ResponseServiceClient } from '../../../common/protocol' ;
19
+ import {
20
+ LibraryPackage ,
21
+ ResponseServiceClient ,
22
+ } from '../../../common/protocol' ;
16
23
import { nls } from '@theia/core/lib/common' ;
17
24
import { FilterRenderer } from './filter-renderer' ;
18
25
import { DisposableCollection } from '@theia/core/lib/common/disposable' ;
@@ -130,13 +137,24 @@ export class FilterableListContainer<
130
137
}
131
138
132
139
private async install ( item : T , version : Installable . Version ) : Promise < void > {
133
- const { install, searchable } = this . props ;
140
+ const { install, searchable, messageService } = this . props ;
141
+ const { name } = item ;
134
142
await ExecuteWithProgress . doWithProgress ( {
135
143
...this . props ,
136
144
progressText :
137
145
nls . localize ( 'arduino/common/processing' , 'Processing' ) +
138
- ` ${ item . name } :${ version } ` ,
139
- run : ( { progressId } ) => install ( { item, progressId, version } ) ,
146
+ ` ${ name } :${ version } ` ,
147
+ run : async ( { progressId } ) => {
148
+ try {
149
+ await install ( { item, progressId, version } ) ;
150
+ } catch ( err ) {
151
+ const message = LibraryPackage . is ( item ) // TODO: this dispatch does not belong here
152
+ ? libraryInstallFailed ( name , version )
153
+ : platformInstallFailed ( name , version ) ;
154
+ const cause = err instanceof Error ? err . message : String ( err ) ;
155
+ messageService . error ( `${ message } ${ cause } ` ) ;
156
+ }
157
+ } ,
140
158
} ) ;
141
159
const items = await searchable . search ( this . state . searchOptions ) ;
142
160
this . setState ( { items, edited : undefined } ) ;
0 commit comments