From cc3fcd1cc61c6b08f84cb8954cbde3955499aa6a Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 4 Jan 2024 15:09:17 +0100 Subject: [PATCH] fix: add custom errors for analytics requests (#2874) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jan Henrik Ă˜verland --- i18n/en.pot | 10 +++++++++ src/components/Visualization/Visualization.js | 8 +++++++ src/modules/error.js | 22 +++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/i18n/en.pot b/i18n/en.pot index ec2d6dac34..10985d66d0 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -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" diff --git a/src/components/Visualization/Visualization.js b/src/components/Visualization/Visualization.js index 0b67d8a528..c619c23760 100644 --- a/src/components/Visualization/Visualization.js +++ b/src/components/Visualization/Visualization.js @@ -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' @@ -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 } diff --git a/src/modules/error.js b/src/modules/error.js index 7f61a71b5a..07160d1aa9 100644 --- a/src/modules/error.js +++ b/src/modules/error.js @@ -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) => {