@@ -594,36 +594,36 @@ class WebSocketTerminal implements vscode.Pseudoterminal {
594594 }
595595}
596596
597+ function reportError ( msg : string , throwErrors = false ) {
598+ if ( throwErrors ) {
599+ throw new Error ( msg ) ;
600+ } else {
601+ vscode . window . showErrorMessage ( msg , "Dismiss" ) ;
602+ }
603+ }
604+
597605function terminalConfigForUri (
598606 api : AtelierAPI ,
599607 extensionUri : vscode . Uri ,
600608 targetUri : vscode . Uri ,
601609 throwErrors = false
602610) : vscode . ExtensionTerminalOptions | undefined {
603- const reportError = ( msg : string ) => {
604- if ( throwErrors ) {
605- throw new Error ( msg ) ;
606- } else {
607- vscode . window . showErrorMessage ( msg , "Dismiss" ) ;
608- }
609- } ;
610-
611611 // Make sure the server connection is active
612612 if ( ! api . active || api . ns == "" ) {
613- reportError ( "WebSocket Terminal requires an active server connection." ) ;
613+ reportError ( "WebSocket Terminal requires an active server connection." , throwErrors ) ;
614614 return ;
615615 }
616616 // Make sure the server has the terminal endpoint
617617 if ( api . config . apiVersion < 7 ) {
618- reportError ( "WebSocket Terminal requires InterSystems IRIS version 2023.2 or above." ) ;
618+ reportError ( "WebSocket Terminal requires InterSystems IRIS version 2023.2 or above." , throwErrors ) ;
619619 return ;
620620 }
621621
622622 return {
623623 name : api . config . serverName && api . config . serverName != "" ? api . config . serverName : "iris" ,
624624 location :
625625 // Mimic what a built-in profile does. When it is the default and the Terminal tab is selected while empty,
626- // an terminal is always created in the Panel.
626+ // a terminal is always created in the Panel.
627627 vscode . workspace . getConfiguration ( "terminal.integrated" , targetUri ) . get ( "defaultLocation" ) === "editor" &&
628628 vscode . window . terminals . length > 0
629629 ? vscode . TerminalLocation . Editor
@@ -634,11 +634,11 @@ function terminalConfigForUri(
634634 } ;
635635}
636636
637- async function workspaceUriForTerminal ( ) {
637+ async function workspaceUriForTerminal ( throwErrors = false ) {
638638 let uri : vscode . Uri ;
639639 const workspaceFolders = vscode . workspace . workspaceFolders || [ ] ;
640640 if ( workspaceFolders . length == 0 ) {
641- throw new Error ( "WebSocket Terminal requires an open workspace." ) ;
641+ reportError ( "WebSocket Terminal requires an open workspace." , throwErrors ) ;
642642 } else if ( workspaceFolders . length == 1 ) {
643643 // Use the current connection
644644 uri = workspaceFolders [ 0 ] . uri ;
@@ -687,7 +687,7 @@ export class WebSocketTerminalProfileProvider implements vscode.TerminalProfileP
687687
688688 async provideTerminalProfile ( _token : vscode . CancellationToken ) : Promise < vscode . TerminalProfile > {
689689 // Determine the server connection to use
690- const uri : vscode . Uri = await workspaceUriForTerminal ( ) ;
690+ const uri : vscode . Uri = await workspaceUriForTerminal ( true ) ;
691691
692692 if ( uri ) {
693693 // Get the terminal configuration. Will throw if there's an error.
0 commit comments