mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-14 06:46:36 +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 { ConfirmDialog } from '@theia/core/lib/browser/dialogs';
|
||||||
import { Searchable } from '../../../common/protocol/searchable';
|
import { Searchable } from '../../../common/protocol/searchable';
|
||||||
import { ExecuteWithProgress } from '../../../common/protocol/progressible';
|
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 { ArduinoComponent } from '../../../common/protocol/arduino-component';
|
||||||
import { SearchBar } from './search-bar';
|
import { SearchBar } from './search-bar';
|
||||||
import { ListWidget } from './list-widget';
|
import { ListWidget } from './list-widget';
|
||||||
import { ComponentList } from './component-list';
|
import { ComponentList } from './component-list';
|
||||||
import { ListItemRenderer } from './list-item-renderer';
|
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 { nls } from '@theia/core/lib/common';
|
||||||
import { FilterRenderer } from './filter-renderer';
|
import { FilterRenderer } from './filter-renderer';
|
||||||
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
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> {
|
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({
|
await ExecuteWithProgress.doWithProgress({
|
||||||
...this.props,
|
...this.props,
|
||||||
progressText:
|
progressText:
|
||||||
nls.localize('arduino/common/processing', 'Processing') +
|
nls.localize('arduino/common/processing', 'Processing') +
|
||||||
` ${item.name}:${version}`,
|
` ${name}:${version}`,
|
||||||
run: ({ progressId }) => install({ item, progressId, 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);
|
const items = await searchable.search(this.state.searchOptions);
|
||||||
this.setState({ items, edited: undefined });
|
this.setState({ items, edited: undefined });
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import type { MessageService } from '@theia/core/lib/common/message-service';
|
import type { MessageService } from '@theia/core/lib/common/message-service';
|
||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
import {
|
import {
|
||||||
coerce as coerceSemver,
|
coerce as coerceSemver,
|
||||||
compare as compareSemver,
|
compare as compareSemver,
|
||||||
@ -9,6 +10,32 @@ import type { ArduinoComponent } from './arduino-component';
|
|||||||
import { ExecuteWithProgress } from './progressible';
|
import { ExecuteWithProgress } from './progressible';
|
||||||
import type { ResponseServiceClient } from './response-service';
|
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> {
|
export interface Installable<T extends ArduinoComponent> {
|
||||||
/**
|
/**
|
||||||
* If `options.version` is specified, that will be installed. Otherwise, `item.availableVersions[0]`.
|
* If `options.version` is specified, that will be installed. Otherwise, `item.availableVersions[0]`.
|
||||||
@ -62,7 +89,7 @@ export namespace Installable {
|
|||||||
'remove',
|
'remove',
|
||||||
'unknown',
|
'unknown',
|
||||||
] as const;
|
] as const;
|
||||||
export type Action = typeof ActionLiterals[number];
|
export type Action = (typeof ActionLiterals)[number];
|
||||||
|
|
||||||
export function action(params: {
|
export function action(params: {
|
||||||
installed?: Version | undefined;
|
installed?: Version | undefined;
|
||||||
|
@ -18,6 +18,7 @@ import {
|
|||||||
BoardSearch,
|
BoardSearch,
|
||||||
sortComponents,
|
sortComponents,
|
||||||
SortGroup,
|
SortGroup,
|
||||||
|
platformInstallFailed,
|
||||||
} from '../common/protocol';
|
} from '../common/protocol';
|
||||||
import {
|
import {
|
||||||
PlatformInstallRequest,
|
PlatformInstallRequest,
|
||||||
@ -474,7 +475,7 @@ export class BoardsServiceImpl
|
|||||||
});
|
});
|
||||||
resp.on('error', (error) => {
|
resp.on('error', (error) => {
|
||||||
this.responseService.appendToOutput({
|
this.responseService.appendToOutput({
|
||||||
chunk: `Failed to install platform: ${item.id}.\n`,
|
chunk: `${platformInstallFailed(item.id, version)}\n`,
|
||||||
});
|
});
|
||||||
this.responseService.appendToOutput({
|
this.responseService.appendToOutput({
|
||||||
chunk: `${error.toString()}\n`,
|
chunk: `${error.toString()}\n`,
|
||||||
|
@ -8,7 +8,10 @@ import {
|
|||||||
sortComponents,
|
sortComponents,
|
||||||
SortGroup,
|
SortGroup,
|
||||||
} from '../common/protocol';
|
} from '../common/protocol';
|
||||||
import { Installable } from '../common/protocol/installable';
|
import {
|
||||||
|
Installable,
|
||||||
|
libraryInstallFailed,
|
||||||
|
} from '../common/protocol/installable';
|
||||||
import {
|
import {
|
||||||
LibraryDependency,
|
LibraryDependency,
|
||||||
LibraryLocation,
|
LibraryLocation,
|
||||||
@ -34,6 +37,7 @@ import {
|
|||||||
} from './cli-protocol/cc/arduino/cli/commands/v1/lib_pb';
|
} from './cli-protocol/cc/arduino/cli/commands/v1/lib_pb';
|
||||||
import { CoreClientAware } from './core-client-provider';
|
import { CoreClientAware } from './core-client-provider';
|
||||||
import { ExecuteWithProgress } from './grpc-progressible';
|
import { ExecuteWithProgress } from './grpc-progressible';
|
||||||
|
import { ServiceError } from './service-error';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class LibraryServiceImpl
|
export class LibraryServiceImpl
|
||||||
@ -272,7 +276,12 @@ export class LibraryServiceImpl
|
|||||||
(resolve, reject) => {
|
(resolve, reject) => {
|
||||||
client.libraryResolveDependencies(req, (error, resp) => {
|
client.libraryResolveDependencies(req, (error, resp) => {
|
||||||
if (error) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
resolve(
|
resolve(
|
||||||
@ -344,9 +353,7 @@ export class LibraryServiceImpl
|
|||||||
});
|
});
|
||||||
resp.on('error', (error) => {
|
resp.on('error', (error) => {
|
||||||
this.responseService.appendToOutput({
|
this.responseService.appendToOutput({
|
||||||
chunk: `Failed to install library: ${item.name}${
|
chunk: `${libraryInstallFailed(item.name, version)}\n`,
|
||||||
version ? `:${version}` : ''
|
|
||||||
}.\n`,
|
|
||||||
});
|
});
|
||||||
this.responseService.appendToOutput({
|
this.responseService.appendToOutput({
|
||||||
chunk: `${error.toString()}\n`,
|
chunk: `${error.toString()}\n`,
|
||||||
|
@ -278,6 +278,10 @@
|
|||||||
"updateAvailable": "Update Available",
|
"updateAvailable": "Update Available",
|
||||||
"versionDownloaded": "Arduino IDE {0} has been downloaded."
|
"versionDownloaded": "Arduino IDE {0} has been downloaded."
|
||||||
},
|
},
|
||||||
|
"installable": {
|
||||||
|
"libraryInstallFailed": "Failed to install library: '{0}{1}'.",
|
||||||
|
"platformInstallFailed": "Failed to install platform: '{0}{1}'."
|
||||||
|
},
|
||||||
"library": {
|
"library": {
|
||||||
"addZip": "Add .ZIP Library...",
|
"addZip": "Add .ZIP Library...",
|
||||||
"arduinoLibraries": "Arduino libraries",
|
"arduinoLibraries": "Arduino libraries",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user