fix: surface connection error messages on the client (#11077)

* fix: surface connection error messages on the client

* typo

* lint
This commit is contained in:
Maxime Beauchemin 2020-09-26 16:09:40 -07:00 committed by GitHub
parent 1493450a6f
commit 7f1e4e441d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -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';
@ -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
@ -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(