Skip to content

Commit

Permalink
Better reporting of debugger connection errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdriscoll committed Jun 18, 2024
1 parent ef44b8c commit d751935
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/commands/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,23 @@ export class UniversalDebugAdapter implements vscode.DebugAdapter {
this.handleMessage(protocolMessage);
});

this.hubConnection.on("error", (message: string) => {
vscode.window.showErrorMessage(message);
});

this.hubConnection.onclose(() => {
vscode.window.showInformationMessage("Disconnected from PowerShell Universal Debugger.");
});

this.hubConnection.start().then(() => {
this.hubConnection?.invoke("connect").then((msg) => {
if (msg.success) {
vscode.window.showInformationMessage(msg.message);
} else {
vscode.window.showErrorMessage(msg.message);
}
});
});
}

private connectionName: string | undefined;
Expand All @@ -86,7 +100,12 @@ export class UniversalDebugAdapter implements vscode.DebugAdapter {

switch (message.type) {
case 'request':
this.hubConnection?.send("message", JSON.stringify(message));
var request = message as DebugProtocol.Request;
if (request.command === 'disconnect') {
this.hubConnection?.stop();
} else {
this.hubConnection?.send("message", JSON.stringify(message));
}
break;
case 'response':
this.sendMessage.fire(message);
Expand Down

0 comments on commit d751935

Please sign in to comment.