Skip to content

Commit

Permalink
fix: surface connection error messages on the client (apache#11077)
Browse files Browse the repository at this point in the history
* fix: surface connection error messages on the client

* typo

* lint
  • Loading branch information
mistercrunch authored Sep 26, 2020
1 parent 1493450 commit 7f1e4e4
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { styled, t, SupersetClient } from '@superset-ui/core';
import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls';
import { useSingleViewResource } from 'src/views/CRUD/hooks';
import withToasts from 'src/messageToasts/enhancers/withToasts';
import getClientErrorObject from 'src/utils/getClientErrorObject';
import Icon from 'src/components/Icon';
import Modal from 'src/common/components/Modal';
import Tabs from 'src/common/components/Tabs';
Expand Down Expand Up @@ -163,11 +164,13 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
.then(() => {
addSuccessToast(t('Connection looks good!'));
})
.catch(() => {
addDangerToast(
t('ERROR: Connection failed, please check your connection settings'),
);
});
.catch(response =>
getClientErrorObject(response).then(error => {
addDangerToast(
t('ERROR: Connection failed. ') + error?.message || '',
);
}),
);
};

// Functions
Expand Down Expand Up @@ -551,7 +554,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
checked={db ? !!db.impersonate_user : false}
onChange={onInputChange}
/>
<div>{t('Impersonate Logged In User (Presto & Hive')}</div>
<div>{t('Impersonate Logged In User (Presto & Hive)')}</div>
<InfoTooltipWithTrigger
label="impersonate"
tooltip={t(
Expand Down

0 comments on commit 7f1e4e4

Please sign in to comment.