@@ -13,7 +13,11 @@ import { signOut } from './commands/signout'
1313import { signIn } from './commands/signin'
1414import { signInSpecifyFlow } from './commands/signinSpecifyFlow'
1515import { isErr } from './utilities/functional/result'
16- import { handleNotSginedInError } from './utilities/errors'
16+ import {
17+ handleNotSginedInError ,
18+ handleSqlmeshLspNotFoundError ,
19+ handleSqlmeshLspDependenciesMissingError ,
20+ } from './utilities/errors'
1721
1822let lspClient : LSPClient | undefined
1923
@@ -58,17 +62,49 @@ export async function activate(context: vscode.ExtensionContext) {
5862 lspClient = new LSPClient ( )
5963 const result = await lspClient . start ( )
6064 if ( isErr ( result ) ) {
61- await handleNotSginedInError ( authProvider )
65+ switch ( result . error . type ) {
66+ case 'not_signed_in' :
67+ await handleNotSginedInError ( authProvider )
68+ break
69+ case 'sqlmesh_lsp_not_found' :
70+ await handleSqlmeshLspNotFoundError ( )
71+ break
72+ case 'sqlmesh_lsp_dependencies_missing' :
73+ await handleSqlmeshLspDependenciesMissingError ( result . error )
74+ break
75+ case 'generic' :
76+ await vscode . window . showErrorMessage (
77+ `Failed to start LSP: ${ result . error . message } ` ,
78+ )
79+ break
80+ }
81+ } else {
82+ context . subscriptions . push ( lspClient )
6283 }
63- context . subscriptions . push ( lspClient )
6484
6585 const restart = async ( ) => {
6686 if ( lspClient ) {
6787 traceVerbose ( 'Restarting LSP client' )
6888 const restartResult = await lspClient . restart ( )
6989 if ( isErr ( restartResult ) ) {
70- await handleNotSginedInError ( authProvider )
90+ switch ( restartResult . error . type ) {
91+ case 'not_signed_in' :
92+ await handleNotSginedInError ( authProvider )
93+ return
94+ case 'sqlmesh_lsp_not_found' :
95+ await handleSqlmeshLspNotFoundError ( )
96+ return
97+ case 'sqlmesh_lsp_dependencies_missing' :
98+ await handleSqlmeshLspDependenciesMissingError ( restartResult . error )
99+ return
100+ case 'generic' :
101+ await vscode . window . showErrorMessage (
102+ `Failed to restart LSP: ${ restartResult . error . message } ` ,
103+ )
104+ return
105+ }
71106 }
107+ context . subscriptions . push ( lspClient )
72108 }
73109 }
74110
0 commit comments