Skip to content

Commit

Permalink
fix: highlight errors when updating devfile (#390)
Browse files Browse the repository at this point in the history
Signed-off-by: vitaliy-guliy <[email protected]>
  • Loading branch information
vitaliy-guliy authored Jul 24, 2024
1 parent eeb3e4a commit 5d23847
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions code/extensions/che-remote/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async function updateDevfile(cheApi: any): Promise<boolean> {
}

const pluginRegistryUrl = process.env.CHE_PLUGIN_REGISTRY_INTERNAL_URL;
console.info(`Using ${pluginRegistryUrl} to generate a new Devfile Context`);
console.info(`Using ${pluginRegistryUrl} to generate new Devfile Context`);

let devfileContext: DevfileContext | undefined = undefined;
try {
Expand All @@ -197,7 +197,11 @@ async function updateDevfile(cheApi: any): Promise<boolean> {
projects: []
}, axiosInstance);
} catch (error) {
const action = await vscode.window.showErrorMessage(`Failed to update Devfile. ${error}`, 'Open Devfile');
const action = await vscode.window.showErrorMessage('Failed to generate new Devfile Context.', {
modal: true,
detail: error.message
}, 'Open Devfile');

if ('Open Devfile' === action) {
const document = await vscode.workspace.openTextDocument(devfilePath);
await vscode.window.showTextDocument(document);
Expand All @@ -220,6 +224,25 @@ async function updateDevfile(cheApi: any): Promise<boolean> {
return false;
}

await devfileService.updateDevfile(devfileContext.devWorkspace.spec?.template);
try {
await devfileService.updateDevfile(devfileContext.devWorkspace.spec?.template);
} catch (error) {
if (error.body && error.body.message) {
const action = await vscode.window.showErrorMessage('Failed to update Devfile.', {
modal: true,
detail: error.body.message
}, 'Open Devfile');

if ('Open Devfile' === action) {
const document = await vscode.workspace.openTextDocument(devfilePath);
await vscode.window.showTextDocument(document);
}
} else {
vscode.window.showErrorMessage(`Failed to update Devfile. ${error}`);
}

return false;
}

return true;
}

0 comments on commit 5d23847

Please sign in to comment.