Clear console and properly handle error message when querying database or containers (#1679)
This commit is contained in:
parent
3a703b0bd0
commit
661f6f4bfb
|
@ -35,14 +35,21 @@ export async function readCollections(databaseId: string): Promise<DataModels.Co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const responses = await Promise.all(promises);
|
try {
|
||||||
responses.forEach((response) => {
|
const responses = await Promise.all(promises);
|
||||||
collections.push(response.resource as DataModels.Collection);
|
responses.forEach((response) => {
|
||||||
});
|
collections.push(response.resource as DataModels.Collection);
|
||||||
|
});
|
||||||
|
|
||||||
// Sort collections by id before returning
|
// Sort collections by id before returning
|
||||||
collections.sort((a, b) => a.id.localeCompare(b.id));
|
collections.sort((a, b) => a.id.localeCompare(b.id));
|
||||||
return collections;
|
return collections;
|
||||||
|
} catch (error) {
|
||||||
|
handleError(error, "ReadCollections", `Error while querying containers for database ${databaseId}`);
|
||||||
|
throw error;
|
||||||
|
} finally {
|
||||||
|
clearMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -22,6 +22,13 @@ export async function readDatabases(): Promise<DataModels.Database[]> {
|
||||||
for (const collectionResourceId in tokensData.resourceTokens) {
|
for (const collectionResourceId in tokensData.resourceTokens) {
|
||||||
// Dictionary key looks like this: dbs/SampleDB/colls/Container
|
// Dictionary key looks like this: dbs/SampleDB/colls/Container
|
||||||
const resourceIdObj = collectionResourceId.split("/");
|
const resourceIdObj = collectionResourceId.split("/");
|
||||||
|
|
||||||
|
if (resourceIdObj.length !== 4) {
|
||||||
|
handleError(`Resource key not recognized: ${resourceIdObj}`, "ReadDatabases", `Error while querying databases`);
|
||||||
|
clearMessage();
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
const databaseId = resourceIdObj[1];
|
const databaseId = resourceIdObj[1];
|
||||||
|
|
||||||
databaseIdsSet.add(databaseId);
|
databaseIdsSet.add(databaseId);
|
||||||
|
@ -37,6 +44,7 @@ export async function readDatabases(): Promise<DataModels.Database[]> {
|
||||||
id: databaseId,
|
id: databaseId,
|
||||||
collections: [],
|
collections: [],
|
||||||
}));
|
}));
|
||||||
|
clearMessage();
|
||||||
return databases;
|
return databases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue