diff --git a/ui/src/kapacitor/components/AlertTabs.js b/ui/src/kapacitor/components/AlertTabs.js index 7889ba0290..af6250d5cd 100644 --- a/ui/src/kapacitor/components/AlertTabs.js +++ b/ui/src/kapacitor/components/AlertTabs.js @@ -92,20 +92,19 @@ class AlertTabs extends Component { } } - handleTestConfig = section => () => { - testAlertOutput(this.props.kapacitor, section, {}) - .then(() => { - this.props.addFlashMessage({ - type: 'success', - text: `Successfully relayed an alert to ${section}.`, - }) + handleTestConfig = section => async () => { + try { + await testAlertOutput(this.props.kapacitor, section, {}) + this.props.addFlashMessage({ + type: 'success', + text: `Successfully relayed an alert to ${section}.`, }) - .catch(() => { - this.props.addFlashMessage({ - type: 'error', - text: `There was an error relaying an alert to ${section}.`, - }) + } catch (error) { + this.props.addFlashMessage({ + type: 'error', + text: `There was an error relaying an alert to ${section}.`, }) + } } sanitizeProperties = (section, properties) => { diff --git a/ui/src/shared/apis/index.js b/ui/src/shared/apis/index.js index e2d6979b0b..8e7b867125 100644 --- a/ui/src/shared/apis/index.js +++ b/ui/src/shared/apis/index.js @@ -152,15 +152,18 @@ export function updateKapacitorConfigSection(kapacitor, section, properties) { }) } -export function testAlertOutput(kapacitor, outputName, properties) { - return kapacitorProxy( - kapacitor, - 'GET', - '/kapacitor/v1/service-tests' - ).then(({data: {services}}) => { +export const testAlertOutput = async (kapacitor, outputName) => { + try { + const {data: {services}} = await kapacitorProxy( + kapacitor, + 'GET', + '/kapacitor/v1/service-tests' + ) const service = services.find(s => s.name === outputName) return kapacitorProxy(kapacitor, 'POST', service.link.href, {}) - }) + } catch (error) { + // empty + } } export function createKapacitorTask(kapacitor, id, type, dbrps, script) {