diff --git a/superset-frontend/src/components/DatabaseSelector/index.tsx b/superset-frontend/src/components/DatabaseSelector/index.tsx index 0c912fd83f30d..020087286f726 100644 --- a/superset-frontend/src/components/DatabaseSelector/index.tsx +++ b/superset-frontend/src/components/DatabaseSelector/index.tsx @@ -194,9 +194,9 @@ export default function DatabaseSelector({ const queryParams = rison.encode({ force: refresh > 0 }); const endpoint = `/api/v1/database/${currentDb.value}/schemas/?q=${queryParams}`; - try { - // TODO: Would be nice to add pagination in a follow-up. Needs endpoint changes. - SupersetClient.get({ endpoint }).then(({ json }) => { + // TODO: Would be nice to add pagination in a follow-up. Needs endpoint changes. + SupersetClient.get({ endpoint }) + .then(({ json }) => { const options = json.result .map((s: string) => ({ value: s, @@ -210,10 +210,12 @@ export default function DatabaseSelector({ onSchemasLoad(options); } setSchemaOptions(options); + setLoadingSchemas(false); + }) + .catch(e => { + setLoadingSchemas(false); + handleError(t('There was an error loading the schemas')); }); - } finally { - setLoadingSchemas(false); - } } }, [currentDb, onSchemasLoad, refresh]); diff --git a/superset-frontend/src/components/TableSelector/index.tsx b/superset-frontend/src/components/TableSelector/index.tsx index 06dad72153722..8e5abe90970b6 100644 --- a/superset-frontend/src/components/TableSelector/index.tsx +++ b/superset-frontend/src/components/TableSelector/index.tsx @@ -189,8 +189,8 @@ const TableSelector: FunctionComponent = ({ setPreviousRefresh(refresh); } - try { - SupersetClient.get({ endpoint }).then(({ json }) => { + SupersetClient.get({ endpoint }) + .then(({ json }) => { const options: TableOption[] = []; let currentTable; json.options.forEach((table: Table) => { @@ -213,10 +213,12 @@ const TableSelector: FunctionComponent = ({ ), ); setCurrentTable(currentTable); + setLoadingTables(false); + }) + .catch(e => { + setLoadingTables(false); + handleError(t('There was an error loading the tables')); }); - } finally { - setLoadingTables(false); - } } // We are using the refresh state to re-trigger the query // previousRefresh should be out of dependencies array