mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-12 13:56:34 +00:00
ATL-653: Added error handling for core/lib install
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
c64ac48fe3
commit
eadc993854
@ -1,6 +1,9 @@
|
||||
import * as React from 'react';
|
||||
import debounce = require('lodash.debounce');
|
||||
import { Event } from '@theia/core/lib/common/event';
|
||||
import { CommandService } from '@theia/core/lib/common/command';
|
||||
import { MessageService } from '@theia/core/lib/common/message-service';
|
||||
import { OutputCommands } from '@theia/output/lib/browser/output-commands';
|
||||
import { ConfirmDialog } from '@theia/core/lib/browser/dialogs';
|
||||
import { Searchable } from '../../../common/protocol/searchable';
|
||||
import { Installable } from '../../../common/protocol/installable';
|
||||
@ -85,9 +88,13 @@ export class FilterableListContainer<T extends ArduinoComponent> extends React.C
|
||||
const dialog = new InstallationProgressDialog(itemLabel(item), version);
|
||||
try {
|
||||
dialog.open();
|
||||
await this.clearArduinoChannel();
|
||||
await install({ item, version });
|
||||
const items = await searchable.search({ query: this.state.filterText });
|
||||
this.setState({ items: this.sort(items) });
|
||||
} catch (error) {
|
||||
this.props.messageService.error(error instanceof Error ? error.message : String(error));
|
||||
throw error;
|
||||
} finally {
|
||||
dialog.close();
|
||||
}
|
||||
@ -106,6 +113,7 @@ export class FilterableListContainer<T extends ArduinoComponent> extends React.C
|
||||
const { uninstall, searchable, itemLabel } = this.props;
|
||||
const dialog = new UninstallationProgressDialog(itemLabel(item));
|
||||
try {
|
||||
await this.clearArduinoChannel();
|
||||
dialog.open();
|
||||
await uninstall({ item });
|
||||
const items = await searchable.search({ query: this.state.filterText });
|
||||
@ -115,6 +123,10 @@ export class FilterableListContainer<T extends ArduinoComponent> extends React.C
|
||||
}
|
||||
}
|
||||
|
||||
private async clearArduinoChannel(): Promise<void> {
|
||||
return this.props.commandService.executeCommand(OutputCommands.CLEAR.id, { name: 'Arduino' });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export namespace FilterableListContainer {
|
||||
@ -129,6 +141,8 @@ export namespace FilterableListContainer {
|
||||
readonly filterTextChangeEvent: Event<string | undefined>;
|
||||
readonly install: ({ item, version }: { item: T, version: Installable.Version }) => Promise<void>;
|
||||
readonly uninstall: ({ item }: { item: T }) => Promise<void>;
|
||||
readonly messageService: MessageService;
|
||||
readonly commandService: CommandService;
|
||||
}
|
||||
|
||||
export interface State<T> {
|
||||
|
@ -5,6 +5,8 @@ import { Deferred } from '@theia/core/lib/common/promise-util';
|
||||
import { Emitter } from '@theia/core/lib/common/event';
|
||||
import { MaybePromise } from '@theia/core/lib/common/types';
|
||||
import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget';
|
||||
import { CommandService } from '@theia/core/lib/common/command';
|
||||
import { MessageService } from '@theia/core/lib/common/message-service';
|
||||
import { Installable } from '../../../common/protocol/installable';
|
||||
import { Searchable } from '../../../common/protocol/searchable';
|
||||
import { ArduinoComponent } from '../../../common/protocol/arduino-component';
|
||||
@ -15,6 +17,12 @@ import { NotificationCenter } from '../../notification-center';
|
||||
@injectable()
|
||||
export abstract class ListWidget<T extends ArduinoComponent> extends ReactWidget {
|
||||
|
||||
@inject(MessageService)
|
||||
protected readonly messageService: MessageService;
|
||||
|
||||
@inject(CommandService)
|
||||
protected readonly commandService: CommandService;
|
||||
|
||||
@inject(NotificationCenter)
|
||||
protected readonly notificationCenter: NotificationCenter;
|
||||
|
||||
@ -87,7 +95,9 @@ export abstract class ListWidget<T extends ArduinoComponent> extends ReactWidget
|
||||
uninstall={this.uninstall.bind(this)}
|
||||
itemLabel={this.options.itemLabel}
|
||||
itemRenderer={this.options.itemRenderer}
|
||||
filterTextChangeEvent={this.filterTextChangeEmitter.event} />;
|
||||
filterTextChangeEvent={this.filterTextChangeEmitter.event}
|
||||
messageService={this.messageService}
|
||||
commandService={this.commandService} />;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,7 +254,11 @@ export class BoardsServiceImpl extends CoreClientAware implements BoardsService
|
||||
});
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
resp.on('end', resolve);
|
||||
resp.on('error', reject);
|
||||
resp.on('error', error => {
|
||||
this.outputService.append({ chunk: `Failed to install platform: ${item.id}.\n` });
|
||||
this.outputService.append({ chunk: error.toString() });
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
const items = await this.search({});
|
||||
|
@ -183,7 +183,11 @@ export class LibraryServiceImpl extends CoreClientAware implements LibraryServic
|
||||
});
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
resp.on('end', resolve);
|
||||
resp.on('error', reject);
|
||||
resp.on('error', error => {
|
||||
this.outputService.append({ chunk: `Failed to install library: ${item.name}${version ? `:${version}` : ''}.\n` });
|
||||
this.outputService.append({ chunk: error.toString() });
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
const items = await this.search({});
|
||||
|
Loading…
x
Reference in New Issue
Block a user