@@ -13,21 +13,49 @@ export type ErrorType =
13
13
// tcloud_bin_not_found is used when the tcloud executable is not found. This is likely to happen if the user
14
14
// opens a project that has a `tcloud.yaml` file but doesn't have tcloud installed.
15
15
| { type : 'tcloud_bin_not_found' }
16
- // sqlmesh_lsp_dependencies_missing is used when the sqlmesh_lsp is found but the lsp extras are missing.
17
16
| SqlmeshLspDependenciesMissingError
18
17
18
+ /**
19
+ * SqlmeshLspDependenciesMissingError is used when the sqlmesh_lsp is found but
20
+ * the lsp extras are missing.
21
+ */
19
22
interface SqlmeshLspDependenciesMissingError {
20
23
type : 'sqlmesh_lsp_dependencies_missing'
21
24
is_missing_pygls : boolean
22
25
is_missing_lsprotocol : boolean
23
26
is_tobiko_cloud : boolean
24
27
}
25
28
29
+ export async function handleError (
30
+ authProvider : AuthenticationProviderTobikoCloud ,
31
+ error : ErrorType ,
32
+ genericErrorPrefix ?: string ,
33
+ ) : Promise < void > {
34
+ traceInfo ( 'handleError' , error )
35
+ switch ( error . type ) {
36
+ case 'not_signed_in' :
37
+ return handleNotSignedInError ( authProvider )
38
+ case 'sqlmesh_lsp_not_found' :
39
+ return handleSqlmeshLspNotFoundError ( )
40
+ case 'sqlmesh_lsp_dependencies_missing' :
41
+ return handleSqlmeshLspDependenciesMissingError ( error )
42
+ case 'tcloud_bin_not_found' :
43
+ return handleTcloudBinNotFoundError ( )
44
+ case 'generic' :
45
+ if ( genericErrorPrefix ) {
46
+ await window . showErrorMessage ( `${ genericErrorPrefix } : ${ error . message } ` )
47
+ } else {
48
+ await window . showErrorMessage ( `An error occurred: ${ error . message } ` )
49
+ }
50
+ return
51
+ }
52
+ }
53
+
26
54
/**
27
55
* Handles the case where the user is not signed in to Tobiko Cloud.
28
56
* @param authProvider - The authentication provider to use for signing in.
29
57
*/
30
- export const handleNotSginedInError = async (
58
+ const handleNotSignedInError = async (
31
59
authProvider : AuthenticationProviderTobikoCloud ,
32
60
) : Promise < void > => {
33
61
traceInfo ( 'handleNotSginedInError' )
@@ -43,7 +71,7 @@ export const handleNotSginedInError = async (
43
71
/**
44
72
* Handles the case where the sqlmesh_lsp is not found.
45
73
*/
46
- export const handleSqlmeshLspNotFoundError = async ( ) : Promise < void > => {
74
+ const handleSqlmeshLspNotFoundError = async ( ) : Promise < void > => {
47
75
traceInfo ( 'handleSqlmeshLspNotFoundError' )
48
76
await window . showErrorMessage (
49
77
'SQLMesh LSP not found, please check installation' ,
@@ -53,7 +81,7 @@ export const handleSqlmeshLspNotFoundError = async (): Promise<void> => {
53
81
/**
54
82
* Handles the case where the sqlmesh_lsp is found but the lsp extras are missing.
55
83
*/
56
- export const handleSqlmeshLspDependenciesMissingError = async (
84
+ const handleSqlmeshLspDependenciesMissingError = async (
57
85
error : SqlmeshLspDependenciesMissingError ,
58
86
) : Promise < void > => {
59
87
traceInfo ( 'handleSqlmeshLspDependenciesMissingError' )
@@ -80,7 +108,7 @@ export const handleSqlmeshLspDependenciesMissingError = async (
80
108
/**
81
109
* Handles the case where the tcloud executable is not found.
82
110
*/
83
- export const handleTcloudBinNotFoundError = async ( ) : Promise < void > => {
111
+ const handleTcloudBinNotFoundError = async ( ) : Promise < void > => {
84
112
const result = await window . showErrorMessage (
85
113
'tcloud executable not found, please check installation' ,
86
114
'Install' ,
0 commit comments