Skip to content

Commit

Permalink
Add better logging while loading databases
Browse files Browse the repository at this point in the history
  • Loading branch information
aeisenberg committed Oct 12, 2022
1 parent 8c324a3 commit 46233b9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions extensions/ql-vscode/src/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,12 @@ export class DatabaseItemImpl implements DatabaseItem {
try {
this._contents = await resolveDatabaseContents(this.databaseUri);
this._error = undefined;
}
catch (e) {
} catch (e) {
this._contents = undefined;
this._error = e instanceof Error ? e : new Error(String(e));
throw e;
}
}
finally {
} finally {
this.onChanged({
kind: DatabaseEventKind.Refresh,
item: this
Expand Down Expand Up @@ -707,6 +705,7 @@ export class DatabaseManager extends DisposableObject {
step
});
try {
void this.logger.log(`Found ${databases.length} persisted databases: ${databases.map(db => db.uri).join(', ')}`);
for (const database of databases) {
progress({
maxStep: databases.length,
Expand All @@ -721,16 +720,19 @@ export class DatabaseManager extends DisposableObject {
if (currentDatabaseUri === database.uri) {
await this.setCurrentDatabaseItem(databaseItem, true);
}
}
catch (e) {
void this.logger.log(`Loaded database ${databaseItem.name} at URI ${database.uri}.`);
} catch (e) {
// When loading from persisted state, leave invalid databases in the list. They will be
// marked as invalid, and cannot be set as the current database.
void this.logger.log(`Error loading database ${database.uri}: ${e}.`);
}
}
} catch (e) {
// database list had an unexpected type - nothing to be done?
void showAndLogErrorMessage(`Database list loading failed: ${getErrorMessage(e)}`);
}

void this.logger.log('Finished loading persisted databases.');
});
}

Expand Down

0 comments on commit 46233b9

Please sign in to comment.