Skip to content

Commit d3cb39b

Browse files
committed
Show error message when creation of customization failed on server
When the server fails to create a customization and replies with an error, show this error to the user as error message and don't show the message that it was successful. Only show success message when the server replied with 200. Fixes #356 Signed-off-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
1 parent 35915f2 commit d3cb39b

5 files changed

Lines changed: 41 additions & 4 deletions

File tree

vscode-trace-common/src/messages/vscode-messages.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const VSCODE_MESSAGES = {
1111
EXPERIMENT_SELECTED: 'experimentSelected',
1212
EXPERIMENT_UPDATED: 'experimentUpdated',
1313
EXPERIMENT_CLOSED: 'experimentClosed',
14+
INFO: 'info',
1415
NEW_STATUS: 'newStatus',
1516
OPENED_TRACES_UPDATED: 'openedTracesUpdated',
1617
OPEN_OVERVIEW: 'open-overview',
@@ -63,6 +64,7 @@ export const setTspClient: NotificationType<any> = { method: VSCODE_MESSAGES.SET
6364
export const connectionStatus: NotificationType<any> = { method: VSCODE_MESSAGES.CONNECTION_STATUS };
6465

6566
export const alert: NotificationType<any> = { method: VSCODE_MESSAGES.ALERT };
67+
export const info: NotificationType<any> = { method: VSCODE_MESSAGES.INFO };
6668
export const newStatus: NotificationType<any> = { method: VSCODE_MESSAGES.NEW_STATUS };
6769
export const removeStatus: NotificationType<any> = { method: VSCODE_MESSAGES.REMOVE_STATUS };
6870

vscode-trace-extension/src/json-editor/json-editor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ export class JsonConfigEditor {
317317
);
318318

319319
if (submit === 'Yes') {
320-
vscode.window.showInformationMessage('Configuration submitted successfully');
321320
return validation.content;
322321
}
323322

vscode-trace-extension/src/trace-explorer/available-views/trace-explorer-available-views-webview-provider.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import {
99
connectionStatus,
1010
outputAdded,
1111
experimentSelected,
12-
setTspClient
12+
setTspClient,
13+
alert,
14+
info
1315
} from 'vscode-trace-common/lib/messages/vscode-messages';
1416
import { ClientType, getTspClientUrl } from 'vscode-trace-extension/src/utils/backend-tsp-client-provider';
1517
import { TraceViewerPanel } from '../../trace-viewer-panel/trace-viewer-webview-panel';
@@ -66,6 +68,14 @@ export class TraceExplorerAvailableViewsProvider extends AbstractTraceExplorerPr
6668
}
6769
};
6870

71+
private readonly _onVscodeAlert = (text: any): void => {
72+
vscode.window.showErrorMessage(text);
73+
};
74+
75+
private readonly _onVscodeInfo = (text: any): void => {
76+
vscode.window.showInformationMessage(text);
77+
};
78+
6979
protected init(
7080
_webviewView: vscode.WebviewView,
7181
_context: vscode.WebviewViewResolveContext,
@@ -82,6 +92,8 @@ export class TraceExplorerAvailableViewsProvider extends AbstractTraceExplorerPr
8292
this._disposables.push(
8393
this._messenger.onNotification<any>(experimentSelected, this._onVscodeExperimentSelected, options)
8494
);
95+
this._disposables.push(this._messenger.onNotification<string>(alert, this._onVscodeAlert, options));
96+
this._disposables.push(this._messenger.onNotification<string>(info, this._onVscodeInfo, options));
8597
signalManager().on('EXPERIMENT_SELECTED', this._onExperimentSelected);
8698
}
8799

vscode-trace-webviews/src/common/vscode-message-manager.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import { Experiment } from 'tsp-typescript-client/lib/models/experiment';
88
import { MarkerSet } from 'tsp-typescript-client/lib/models/markerset';
99
import { HOST_EXTENSION, MessageParticipant, MessengerAPI } from 'vscode-messenger-common';
1010
import {
11+
alert,
1112
closeTrace,
1213
contextMenuItemClicked,
1314
deleteTrace,
1415
experimentClosed,
1516
experimentSelected,
1617
experimentUpdated,
18+
info,
1719
markerCategoryContext,
1820
markerSetsContext,
1921
newStatus,
@@ -73,6 +75,14 @@ export class VsCodeMessageManager extends Messages.MessageManager implements Sta
7375
this._messenger.sendNotification(connectionStatus, _receiver ?? HOST_EXTENSION, { status });
7476
}
7577

78+
notifyError(message: string, _receiver?: MessageParticipant | undefined): void {
79+
this._messenger.sendNotification(alert, _receiver ?? HOST_EXTENSION, message);
80+
}
81+
82+
notifyInfo(message: string, _receiver?: MessageParticipant | undefined): void {
83+
this._messenger.sendNotification(info, _receiver ?? HOST_EXTENSION, message);
84+
}
85+
7686
/**************************************************************************
7787
* Trace Explorer React APP
7888
*************************************************************************/

vscode-trace-webviews/src/trace-explorer/available-views/vscode-trace-explorer-views-widget.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,22 @@ class TraceExplorerViewsWidget extends React.Component<{}, AvailableViewsAppStat
108108
const { name, description, sourceTypeId, parameters } = userConfig;
109109

110110
const options = new OutputConfigurationQuery(name, description, sourceTypeId, parameters);
111-
await tsp.createDerivedOutput(experiment.UUID, output.id, options);
112-
return;
111+
const response = await tsp.createDerivedOutput(experiment.UUID, output.id, options);
112+
if (!response.isOk()) {
113+
const errorResponse = response.getErrorResponse();
114+
let message: string = `Customization failed (${response.getStatusCode()}): '${response.getStatusMessage()}'`;
115+
if (errorResponse) {
116+
message = `Customization failed (${response.getStatusCode()}): '${errorResponse.title}'`;
117+
// TODO Remove workaround when following fix is available
118+
// https://github.com/eclipse-cdt-cloud/tsp-typescript-client/issues/148
119+
if ('detail' in errorResponse) {
120+
message = message + `. Details: '${errorResponse.detail}'`;
121+
}
122+
}
123+
this._signalHandler.notifyError(message);
124+
return;
125+
}
126+
this._signalHandler.notifyInfo('Configuration submitted successfully');
113127
};
114128

115129
public render(): React.ReactNode {

0 commit comments

Comments
 (0)