From bf13e339fe99102ea873390a5c830757fb9d6483 Mon Sep 17 00:00:00 2001 From: Ariel Salem Date: Thu, 21 May 2020 12:21:12 -0700 Subject: [PATCH] chore(reduce_honeybadger_noise): saveCheckFromTimeMachine was reporting Honeybadger errors when users were trying to save checks with the same name. (#18188) --- ui/src/checks/actions/thunks.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ui/src/checks/actions/thunks.ts b/ui/src/checks/actions/thunks.ts index d0b53cb4ca..f200393adc 100644 --- a/ui/src/checks/actions/thunks.ts +++ b/ui/src/checks/actions/thunks.ts @@ -19,6 +19,7 @@ import {createView} from 'src/views/helpers' import {getOrg} from 'src/organizations/selectors' import {toPostCheck, builderToPostCheck} from 'src/checks/utils' import {getAll, getStatus} from 'src/resources/selectors' +import {getErrorMessage} from 'src/utils/api' // Actions import { @@ -151,17 +152,14 @@ export const createCheckFromTimeMachine = () => async ( dispatch: Dispatch, getState: GetState ): Promise => { + const rename = 'Please rename the check before saving' try { const state = getState() const check = builderToPostCheck(state) const resp = await api.postCheck({data: check}) if (resp.status !== 201) { if (resp.data.code.includes('conflict')) { - throw new Error( - `A check named ${ - check.name - } already exists. Please rename the check before saving` - ) + throw new Error(`A check named ${check.name} already exists. ${rename}`) } throw new Error(resp.data.message) } @@ -178,11 +176,14 @@ export const createCheckFromTimeMachine = () => async ( dispatch(resetAlertBuilder()) } catch (error) { console.error(error) - dispatch(notify(copy.createCheckFailed(error.message))) - reportError(error, { - context: {state: getState()}, - name: 'saveCheckFromTimeMachine function', - }) + const message = getErrorMessage(error) + dispatch(notify(copy.createCheckFailed(message))) + if (!message.includes(rename)) { + reportError(error, { + context: {state: getState()}, + name: 'saveCheckFromTimeMachine function', + }) + } } }