@@ -593,15 +593,27 @@ class WebSocketTerminal implements vscode.Pseudoterminal {
593
593
}
594
594
}
595
595
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
+
597
609
// Make sure the server connection is active
598
610
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." ) ;
600
612
return ;
601
613
}
602
614
// Make sure the server has the terminal endpoint
603
615
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." ) ;
605
617
return ;
606
618
}
607
619
@@ -635,7 +647,7 @@ export class WebSocketTerminalProfileProvider implements vscode.TerminalProfileP
635
647
let uri : vscode . Uri ;
636
648
const workspaceFolders = vscode . workspace . workspaceFolders || [ ] ;
637
649
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." ) ;
639
651
} else if ( workspaceFolders . length == 1 ) {
640
652
// Use the current connection
641
653
uri = workspaceFolders [ 0 ] . uri ;
@@ -644,17 +656,17 @@ export class WebSocketTerminalProfileProvider implements vscode.TerminalProfileP
644
656
uri = (
645
657
await vscode . window . showWorkspaceFolderPick ( {
646
658
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" ,
648
660
} )
649
661
) ?. uri ;
650
662
}
651
663
652
664
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." ) ;
658
670
}
659
671
}
660
672
}
0 commit comments