Skip to content

Commit

Permalink
fix: add custom errors for analytics requests (#445)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Henrik Øverland <[email protected]>
  • Loading branch information
2 people authored and edoardo committed Jan 4, 2024
1 parent 367f00a commit 6e78c34
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
19 changes: 19 additions & 0 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,25 @@ msgstr "You don’t have access to event analytics. Contact a system administrat
msgid "Something went wrong"
msgstr "Something went wrong"

msgid ""
"There's a problem with the generated analytics. Contact a system "
"administrator."
msgstr ""
"There's a problem with the generated analytics. Contact a system "
"administrator."

msgid "There's a syntax problem with the analytics request."
msgstr "There's a syntax problem with the analytics request."

msgid "Organisation unit"
msgstr "Organisation unit"

msgid "Event status"
msgstr "Event status"

msgid "Program status"
msgstr "Program status"

msgid "Last updated on"
msgstr "Last updated on"

Expand Down
8 changes: 8 additions & 0 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { acSetVisualization } from '../actions/visualization.js'
import { parseCondition, OPERATOR_IN } from '../modules/conditions.js'
import { EVENT_TYPE } from '../modules/dataStatistics.js'
import {
analyticsGenerationError,
analyticsRequestError,
dataAccessError,
emptyResponseError,
eventAccessError,
Expand Down Expand Up @@ -247,6 +249,12 @@ const App = () => {
case 'E7217':
output = eventAccessError()
break
case 'E7144':
output = analyticsGenerationError()
break
case 'E7145':
output = analyticsRequestError()
break
default:
output = genericServerError()
}
Expand Down
16 changes: 16 additions & 0 deletions src/modules/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ export const eventAccessError = () =>
)
)

export const analyticsGenerationError = () =>
visualizationError(
GenericError,
i18n.t('Something went wrong'),
i18n.t(
"There's a problem with the generated analytics. Contact a system administrator."
)
)

export const analyticsRequestError = () =>
visualizationError(
GenericError,
i18n.t('Something went wrong'),
i18n.t("There's a syntax problem with the analytics request.")
)

export const getAlertTypeByStatusCode = (statusCode) =>
String(statusCode).match(/50\d/) ? 'error' : 'warning'

Expand Down

0 comments on commit 6e78c34

Please sign in to comment.