Skip to content

Commit

Permalink
fix: add custom errors for analytics requests (#2874)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Henrik Øverland <[email protected]>
  • Loading branch information
martinkrulltott and janhenrikoverland authored Jan 4, 2024
1 parent fb706cf commit cc3fcd1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,16 @@ msgstr ""
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 "or"
msgstr "or"

Expand Down
8 changes: 8 additions & 0 deletions src/components/Visualization/Visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
NoOrgUnitResponseError,
NoDataError,
ValueTypeError,
AnalyticsGenerationError,
AnalyticsRequestError,
} from '../../modules/error.js'
import { removeLastPathSegment } from '../../modules/orgUnit.js'
import { sGetCurrent } from '../../reducers/current.js'
Expand Down Expand Up @@ -74,6 +76,12 @@ export class UnconnectedVisualization extends Component {
}
}
break
case 'E7144':
error = new AnalyticsGenerationError()
break
case 'E7145':
error = new AnalyticsRequestError()
break
default:
error = response
}
Expand Down
22 changes: 22 additions & 0 deletions src/modules/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,28 @@ export class ValueTypeError extends VisualizationError {
}
}

export class AnalyticsGenerationError extends VisualizationError {
constructor() {
super(
GenericError,
i18n.t('Something went wrong'),
i18n.t(
"There's a problem with the generated analytics. Contact a system administrator."
)
)
}
}

export class AnalyticsRequestError extends VisualizationError {
constructor() {
super(
GenericError,
i18n.t('Something went wrong'),
i18n.t("There's a syntax problem with the analytics request.")
)
}
}

export const genericErrorTitle = i18n.t('Something went wrong')

const getAvailableAxesDescription = (visType) => {
Expand Down

0 comments on commit cc3fcd1

Please sign in to comment.