Skip to content

Commit 5855d1d

Browse files
committed
TraceServer: Show error messages beside logging it
While still logging errors to the console, also show them to the user as actual messages, for explicit UX purposes. Such error messages show as sticky, thus each has to be closed by the user. These messages are likely more useful when [1] below isn't installed alongside this extension. Meaning, when [1]'s provided server status bar item isn't present to show similar statuses. [1] https://github.com/eclipse-cdt-cloud/vscode-trace-extension Contributes to fixing #8. Signed-off-by: Marco Miller <marco.miller@ericsson.com>
1 parent f9375aa commit 5855d1d

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/trace-server.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class TraceServer {
2222
const server = spawn(this.getPath(from), this.getArgs(from));
2323

2424
if (!server.pid) {
25-
console.error(prefix + ' startup' + suffix);
25+
this.showError(prefix + ' startup' + suffix);
2626
return;
2727
}
2828
this.server = server;
@@ -56,9 +56,9 @@ export class TraceServer {
5656
const message = prefix + ' stopping' + suffix;
5757
treeKill(pid, error => {
5858
if (error) {
59-
console.error(message);
59+
this.showError(message);
6060
} else {
61-
id = setTimeout(() => console.error(message), millis);
61+
id = setTimeout(() => this.showError(message), millis);
6262
}
6363
});
6464
}
@@ -140,7 +140,7 @@ export class TraceServer {
140140
break;
141141
}
142142
if (timeout) {
143-
console.error(prefix + ' startup timed-out after ' + millis + 'ms.');
143+
this.showError(prefix + ' startup timed-out after ' + millis + 'ms.');
144144
this.stopOrReset(context);
145145
break;
146146
}
@@ -149,6 +149,11 @@ export class TraceServer {
149149
);
150150
}
151151

152+
private showError(message: string) {
153+
console.error(message);
154+
vscode.window.showErrorMessage(message);
155+
}
156+
152157
private showStatus(started: boolean) {
153158
if (started) {
154159
vscode.window.showInformationMessage(prefix + ': Started.');

0 commit comments

Comments
 (0)