Clear console and properly handle error message when querying database or containers (#1679)
This commit is contained in:
parent
3a703b0bd0
commit
661f6f4bfb
|
@ -35,6 +35,7 @@ export async function readCollections(databaseId: string): Promise<DataModels.Co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const responses = await Promise.all(promises);
|
const responses = await Promise.all(promises);
|
||||||
responses.forEach((response) => {
|
responses.forEach((response) => {
|
||||||
collections.push(response.resource as DataModels.Collection);
|
collections.push(response.resource as DataModels.Collection);
|
||||||
|
@ -43,6 +44,12 @@ export async function readCollections(databaseId: string): Promise<DataModels.Co
|
||||||
// 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