Skip to content

Commit f6d3f74

Browse files
committed
John's comments
1 parent be10cfd commit f6d3f74

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

src/commands/webSocketTerminal.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -593,15 +593,27 @@ class WebSocketTerminal implements vscode.Pseudoterminal {
593593
}
594594
}
595595

596-
function terminalConfigForUri(api: AtelierAPI, extensionUri: vscode.Uri): vscode.ExtensionTerminalOptions | undefined {
596+
function terminalConfigForUri(
597+
api: AtelierAPI,
598+
extensionUri: vscode.Uri,
599+
throwErrors = false
600+
): vscode.ExtensionTerminalOptions | undefined {
601+
const reportError = (msg: string) => {
602+
if (throwErrors) {
603+
throw new Error(msg);
604+
} else {
605+
vscode.window.showErrorMessage(msg, "Dismiss");
606+
}
607+
};
608+
597609
// Make sure the server connection is active
598610
if (!api.active || api.ns == "") {
599-
vscode.window.showErrorMessage("WebSocket Terminal requires an active server connection.", "Dismiss");
611+
reportError("WebSocket Terminal requires an active server connection.");
600612
return;
601613
}
602614
// Make sure the server has the terminal endpoint
603615
if (api.config.apiVersion < 7) {
604-
vscode.window.showErrorMessage("WebSocket Terminal requires Atelier API version 7 or above.", "Dismiss");
616+
reportError("WebSocket Terminal requires InterSystems IRIS version 2023.2 or above.");
605617
return;
606618
}
607619

@@ -635,7 +647,7 @@ export class WebSocketTerminalProfileProvider implements vscode.TerminalProfileP
635647
let uri: vscode.Uri;
636648
const workspaceFolders = vscode.workspace.workspaceFolders || [];
637649
if (workspaceFolders.length == 0) {
638-
vscode.window.showErrorMessage("WebSocket Terminal requires an open workspace.", "Dismiss");
650+
throw new Error("WebSocket Terminal requires an open workspace.");
639651
} else if (workspaceFolders.length == 1) {
640652
// Use the current connection
641653
uri = workspaceFolders[0].uri;
@@ -644,17 +656,17 @@ export class WebSocketTerminalProfileProvider implements vscode.TerminalProfileP
644656
uri = (
645657
await vscode.window.showWorkspaceFolderPick({
646658
ignoreFocusOut: true,
647-
placeHolder: "Pick the workspace folder to get server connection info from.",
659+
placeHolder: "Pick the workspace folder to get server connection information from",
648660
})
649661
)?.uri;
650662
}
651663

652664
if (uri) {
653-
// Get the terminal configuration
654-
const terminalOpts = terminalConfigForUri(new AtelierAPI(uri), this._extensionUri);
655-
if (terminalOpts) {
656-
return new vscode.TerminalProfile(terminalOpts);
657-
}
665+
// Get the terminal configuration. Will throw if there's an error.
666+
const terminalOpts = terminalConfigForUri(new AtelierAPI(uri), this._extensionUri, true);
667+
return new vscode.TerminalProfile(terminalOpts);
668+
} else {
669+
throw new Error("WebSocket Terminal requires a selected workspace folder.");
658670
}
659671
}
660672
}

0 commit comments

Comments
 (0)