Skip to content

Commit 2baae84

Browse files
committed
Catch and report error when selecting invalid database
1 parent bba2f02 commit 2baae84

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

extensions/ql-vscode/src/databases-ui.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,17 @@ export class DatabaseUI extends DisposableObject {
297297
}
298298

299299
private handleSetCurrentDatabase = async (uri: Uri): Promise<DatabaseItem | undefined> => {
300-
// Assume user has selected an archive if the file has a .zip extension
301-
if (uri.path.endsWith('.zip')) {
302-
return await importArchiveDatabase(uri.toString(true), this.databaseManager, this.storagePath);
303-
}
300+
try {
301+
// Assume user has selected an archive if the file has a .zip extension
302+
if (uri.path.endsWith('.zip')) {
303+
return await importArchiveDatabase(uri.toString(true), this.databaseManager, this.storagePath);
304+
}
304305

305-
return await this.setCurrentDatabase(uri);
306+
return await this.setCurrentDatabase(uri);
307+
} catch (e) {
308+
showAndLogErrorMessage(`Could not set database to ${path.basename(uri.fsPath)}. Reason: ${e.message}`);
309+
return undefined;
310+
}
306311
}
307312

308313
private handleRemoveDatabase = (databaseItem: DatabaseItem): void => {

0 commit comments

Comments
 (0)