chore(reduce_honeybadger_noise): saveCheckFromTimeMachine was reporting Honeybadger errors when users were trying to save checks with the same name. (#18188)
parent
99074a262d
commit
bf13e339fe
|
@ -19,6 +19,7 @@ import {createView} from 'src/views/helpers'
|
||||||
import {getOrg} from 'src/organizations/selectors'
|
import {getOrg} from 'src/organizations/selectors'
|
||||||
import {toPostCheck, builderToPostCheck} from 'src/checks/utils'
|
import {toPostCheck, builderToPostCheck} from 'src/checks/utils'
|
||||||
import {getAll, getStatus} from 'src/resources/selectors'
|
import {getAll, getStatus} from 'src/resources/selectors'
|
||||||
|
import {getErrorMessage} from 'src/utils/api'
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
import {
|
import {
|
||||||
|
@ -151,17 +152,14 @@ export const createCheckFromTimeMachine = () => async (
|
||||||
dispatch: Dispatch<Action | SendToTimeMachineAction>,
|
dispatch: Dispatch<Action | SendToTimeMachineAction>,
|
||||||
getState: GetState
|
getState: GetState
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
|
const rename = 'Please rename the check before saving'
|
||||||
try {
|
try {
|
||||||
const state = getState()
|
const state = getState()
|
||||||
const check = builderToPostCheck(state)
|
const check = builderToPostCheck(state)
|
||||||
const resp = await api.postCheck({data: check})
|
const resp = await api.postCheck({data: check})
|
||||||
if (resp.status !== 201) {
|
if (resp.status !== 201) {
|
||||||
if (resp.data.code.includes('conflict')) {
|
if (resp.data.code.includes('conflict')) {
|
||||||
throw new Error(
|
throw new Error(`A check named ${check.name} already exists. ${rename}`)
|
||||||
`A check named ${
|
|
||||||
check.name
|
|
||||||
} already exists. Please rename the check before saving`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
throw new Error(resp.data.message)
|
throw new Error(resp.data.message)
|
||||||
}
|
}
|
||||||
|
@ -178,11 +176,14 @@ export const createCheckFromTimeMachine = () => async (
|
||||||
dispatch(resetAlertBuilder())
|
dispatch(resetAlertBuilder())
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
dispatch(notify(copy.createCheckFailed(error.message)))
|
const message = getErrorMessage(error)
|
||||||
reportError(error, {
|
dispatch(notify(copy.createCheckFailed(message)))
|
||||||
context: {state: getState()},
|
if (!message.includes(rename)) {
|
||||||
name: 'saveCheckFromTimeMachine function',
|
reportError(error, {
|
||||||
})
|
context: {state: getState()},
|
||||||
|
name: 'saveCheckFromTimeMachine function',
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue