mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-13 14:26:37 +00:00
fix: show notification if lib/core install failed
Closes #621 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
parent
36e2092398
commit
278dd4ba87
@ -6,13 +6,20 @@ import { MessageService } from '@theia/core/lib/common/message-service';
|
||||
import { ConfirmDialog } from '@theia/core/lib/browser/dialogs';
|
||||
import { Searchable } from '../../../common/protocol/searchable';
|
||||
import { ExecuteWithProgress } from '../../../common/protocol/progressible';
|
||||
import { Installable } from '../../../common/protocol/installable';
|
||||
import {
|
||||
Installable,
|
||||
libraryInstallFailed,
|
||||
platformInstallFailed,
|
||||
} from '../../../common/protocol/installable';
|
||||
import { ArduinoComponent } from '../../../common/protocol/arduino-component';
|
||||
import { SearchBar } from './search-bar';
|
||||
import { ListWidget } from './list-widget';
|
||||
import { ComponentList } from './component-list';
|
||||
import { ListItemRenderer } from './list-item-renderer';
|
||||
import { ResponseServiceClient } from '../../../common/protocol';
|
||||
import {
|
||||
LibraryPackage,
|
||||
ResponseServiceClient,
|
||||
} from '../../../common/protocol';
|
||||
import { nls } from '@theia/core/lib/common';
|
||||
import { FilterRenderer } from './filter-renderer';
|
||||
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
||||
@ -130,13 +137,24 @@ export class FilterableListContainer<
|
||||
}
|
||||
|
||||
private async install(item: T, version: Installable.Version): Promise<void> {
|
||||
const { install, searchable } = this.props;
|
||||
const { install, searchable, messageService } = this.props;
|
||||
const { name } = item;
|
||||
await ExecuteWithProgress.doWithProgress({
|
||||
...this.props,
|
||||
progressText:
|
||||
nls.localize('arduino/common/processing', 'Processing') +
|
||||
` ${item.name}:${version}`,
|
||||
run: ({ progressId }) => install({ item, progressId, version }),
|
||||
` ${name}:${version}`,
|
||||
run: async ({ progressId }) => {
|
||||
try {
|
||||
await install({ item, progressId, version });
|
||||
} catch (err) {
|
||||
const message = LibraryPackage.is(item) // TODO: this dispatch does not belong here
|
||||
? libraryInstallFailed(name, version)
|
||||
: platformInstallFailed(name, version);
|
||||
const cause = err instanceof Error ? err.message : String(err);
|
||||
messageService.error(`${message} ${cause}`);
|
||||
}
|
||||
},
|
||||
});
|
||||
const items = await searchable.search(this.state.searchOptions);
|
||||
this.setState({ items, edited: undefined });
|
||||
|
@ -1,4 +1,5 @@
|
||||
import type { MessageService } from '@theia/core/lib/common/message-service';
|
||||
import { nls } from '@theia/core/lib/common/nls';
|
||||
import {
|
||||
coerce as coerceSemver,
|
||||
compare as compareSemver,
|
||||
@ -9,6 +10,32 @@ import type { ArduinoComponent } from './arduino-component';
|
||||
import { ExecuteWithProgress } from './progressible';
|
||||
import type { ResponseServiceClient } from './response-service';
|
||||
|
||||
export function libraryInstallFailed(
|
||||
name: string,
|
||||
version?: string | undefined
|
||||
): string {
|
||||
const versionSuffix = version ? `:${version}` : '';
|
||||
return nls.localize(
|
||||
'arduino/installable/libraryInstallFailed',
|
||||
"Failed to install library: '{0}{1}'.",
|
||||
name,
|
||||
versionSuffix
|
||||
);
|
||||
}
|
||||
|
||||
export function platformInstallFailed(
|
||||
name: string,
|
||||
version?: string | undefined
|
||||
): string {
|
||||
const versionSuffix = version ? `:${version}` : '';
|
||||
return nls.localize(
|
||||
'arduino/installable/platformInstallFailed',
|
||||
"Failed to install platform: '{0}{1}'.",
|
||||
name,
|
||||
versionSuffix
|
||||
);
|
||||
}
|
||||
|
||||
export interface Installable<T extends ArduinoComponent> {
|
||||
/**
|
||||
* If `options.version` is specified, that will be installed. Otherwise, `item.availableVersions[0]`.
|
||||
@ -62,7 +89,7 @@ export namespace Installable {
|
||||
'remove',
|
||||
'unknown',
|
||||
] as const;
|
||||
export type Action = typeof ActionLiterals[number];
|
||||
export type Action = (typeof ActionLiterals)[number];
|
||||
|
||||
export function action(params: {
|
||||
installed?: Version | undefined;
|
||||
|
@ -18,6 +18,7 @@ import {
|
||||
BoardSearch,
|
||||
sortComponents,
|
||||
SortGroup,
|
||||
platformInstallFailed,
|
||||
} from '../common/protocol';
|
||||
import {
|
||||
PlatformInstallRequest,
|
||||
@ -474,7 +475,7 @@ export class BoardsServiceImpl
|
||||
});
|
||||
resp.on('error', (error) => {
|
||||
this.responseService.appendToOutput({
|
||||
chunk: `Failed to install platform: ${item.id}.\n`,
|
||||
chunk: `${platformInstallFailed(item.id, version)}\n`,
|
||||
});
|
||||
this.responseService.appendToOutput({
|
||||
chunk: `${error.toString()}\n`,
|
||||
|
@ -8,7 +8,10 @@ import {
|
||||
sortComponents,
|
||||
SortGroup,
|
||||
} from '../common/protocol';
|
||||
import { Installable } from '../common/protocol/installable';
|
||||
import {
|
||||
Installable,
|
||||
libraryInstallFailed,
|
||||
} from '../common/protocol/installable';
|
||||
import {
|
||||
LibraryDependency,
|
||||
LibraryLocation,
|
||||
@ -34,6 +37,7 @@ import {
|
||||
} from './cli-protocol/cc/arduino/cli/commands/v1/lib_pb';
|
||||
import { CoreClientAware } from './core-client-provider';
|
||||
import { ExecuteWithProgress } from './grpc-progressible';
|
||||
import { ServiceError } from './service-error';
|
||||
|
||||
@injectable()
|
||||
export class LibraryServiceImpl
|
||||
@ -272,7 +276,12 @@ export class LibraryServiceImpl
|
||||
(resolve, reject) => {
|
||||
client.libraryResolveDependencies(req, (error, resp) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
console.error('Failed to list library dependencies', error);
|
||||
// If a gRPC service error, it removes the code and the number to provider more readable error message to the user.
|
||||
const unwrappedError = ServiceError.is(error)
|
||||
? new Error(error.details)
|
||||
: error;
|
||||
reject(unwrappedError);
|
||||
return;
|
||||
}
|
||||
resolve(
|
||||
@ -344,9 +353,7 @@ export class LibraryServiceImpl
|
||||
});
|
||||
resp.on('error', (error) => {
|
||||
this.responseService.appendToOutput({
|
||||
chunk: `Failed to install library: ${item.name}${
|
||||
version ? `:${version}` : ''
|
||||
}.\n`,
|
||||
chunk: `${libraryInstallFailed(item.name, version)}\n`,
|
||||
});
|
||||
this.responseService.appendToOutput({
|
||||
chunk: `${error.toString()}\n`,
|
||||
|
@ -278,6 +278,10 @@
|
||||
"updateAvailable": "Update Available",
|
||||
"versionDownloaded": "Arduino IDE {0} has been downloaded."
|
||||
},
|
||||
"installable": {
|
||||
"libraryInstallFailed": "Failed to install library: '{0}{1}'.",
|
||||
"platformInstallFailed": "Failed to install platform: '{0}{1}'."
|
||||
},
|
||||
"library": {
|
||||
"addZip": "Add .ZIP Library...",
|
||||
"arduinoLibraries": "Arduino libraries",
|
||||
|
Loading…
x
Reference in New Issue
Block a user