From fb45571bc716509f267235f132db2a6360128893 Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Thu, 15 Jan 2026 16:22:04 +0100 Subject: [PATCH 01/10] Add diagram errors and restore business error mechanism --- src/services/utils.ts | 8 +----- src/translations/en/businessErrorsEn.ts | 8 ++++++ src/translations/fr/businessErrorsFr.ts | 9 +++++++ src/utils/error.ts | 4 +-- src/utils/types/CustomError.ts | 34 ------------------------- src/utils/types/ProblemDetailError.ts | 25 +++++++++++++++--- src/utils/types/index.ts | 1 - 7 files changed, 40 insertions(+), 49 deletions(-) delete mode 100644 src/utils/types/CustomError.ts diff --git a/src/services/utils.ts b/src/services/utils.ts index ec817b4b..b3d04766 100644 --- a/src/services/utils.ts +++ b/src/services/utils.ts @@ -8,7 +8,6 @@ import { getUserToken } from '../redux/commonStore'; import { ProblemDetailError } from '../utils/types/ProblemDetailError'; import { NetworkTimeoutError } from '../utils/types/NetworkTimeoutError'; -import { CustomError } from '../utils/types/CustomError'; const DEFAULT_TIMEOUT_MS = 50_000; @@ -76,12 +75,7 @@ export const convertToCustomError = (textError: string) => { errorJson.businessErrorValues ); } - return new CustomError( - errorJson.detail, - errorJson.status, - errorJson.businessErrorCode, - errorJson.businessErrorValues - ); + return new Error(textError); }; const handleError = (response: Response) => { diff --git a/src/translations/en/businessErrorsEn.ts b/src/translations/en/businessErrorsEn.ts index 3b6c1335..694620bc 100644 --- a/src/translations/en/businessErrorsEn.ts +++ b/src/translations/en/businessErrorsEn.ts @@ -66,4 +66,12 @@ export const businessErrorsEn = { 'Only last rule can have empty filter: type {equipmentType}, rule index {index}.', 'sensitivityAnalysis.tooManyFactors': 'Too many factors to run sensitivity analysis: {resultCount} results (limit: {resultCountLimit}) and {variableCount} variables (limit: {variableCountLimit}).', + 'singleLineDiagram.equipmentNotFound': 'Voltage level or substation {id} not found', + 'singleLineDiagram.maxVoltageLevelDisplayed': + 'You need to reduce the number of voltage levels to be displayed in the network area diagram (current {nbVoltageLevels}, maximum {maxVoltageLevels})', + 'singleLineDiagram.invalidConfigRequest': "Given sld display mode '{sldDisplayMode}' doesn't exist", + 'singleLineDiagram.invalidEquipment': + "Given equipment '{id}' of type '{equipmentType}' is not a substation or voltage level id in given network", + 'singleLineDiagram.invalidSubstationLayout': "Mode d'affichage de site '{substationLayout}' invalide", + 'singleLineDiagram.noVoltageLevelIdProvided': 'Aucun poste trouvé', }; diff --git a/src/translations/fr/businessErrorsFr.ts b/src/translations/fr/businessErrorsFr.ts index efef5ba2..b7b2776d 100644 --- a/src/translations/fr/businessErrorsFr.ts +++ b/src/translations/fr/businessErrorsFr.ts @@ -67,4 +67,13 @@ export const businessErrorsFr = { 'Seule la dernière règle peut avoir un filtre vide : type {equipmentType}, indice de la règle : {index}.', 'sensitivityAnalysis.tooManyFactors': 'Trop de facteurs pour exécuter l’analyse de sensibilité : {resultCount} résultats (limite : {resultCountLimit}) et {variableCount} variables (limite : {variableCountLimit}).', + 'singleLineDiagram.equipmentNotFound': 'Voltage level or substation {id} not found', + 'singleLineDiagram.maxVoltageLevelDisplayed': + "Vous devez réduire le nombre de postes à afficher dans l'image nodale de zone (nombre actuel {nbVoltageLevels}, nombre maximum {maxVoltageLevels})", + 'singleLineDiagram.invalidConfigRequest': + "Le mode d'affichage de schéma unifilaire '{sldDisplayMode}' n'existe pas", + 'singleLineDiagram.invalidEquipment': + "L'équipement '{id}' de type '{equipmentType}' n'est pas un site ou poste dans le réseau courant", + 'singleLineDiagram.invalidSubstationLayout': "Substation layout '{substationLayout}' incorrect", + 'singleLineDiagram.noVoltageLevelIdProvided': 'No voltage level was found', }; diff --git a/src/utils/error.ts b/src/utils/error.ts index df0a4a20..8d26350b 100644 --- a/src/utils/error.ts +++ b/src/utils/error.ts @@ -5,11 +5,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { SnackInputs, UseSnackMessageReturn } from '../hooks/useSnackMessage'; -import { ProblemDetailError } from './types/ProblemDetailError'; +import { ProblemDetailError, formatMessageValues } from './types/ProblemDetailError'; import { NetworkTimeoutError } from './types/NetworkTimeoutError'; -import { formatMessageValues } from './types'; - export type HeaderSnackInputs = Pick; export function catchErrorHandler(error: unknown, callback: (message: string) => void) { diff --git a/src/utils/types/CustomError.ts b/src/utils/types/CustomError.ts deleted file mode 100644 index ddbada34..00000000 --- a/src/utils/types/CustomError.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2025, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -export class CustomError extends Error { - status: number; - - businessErrorCode?: string; - - businessErrorValues?: Record; - - constructor( - message: string, - status: number, - businessErrorCode?: string, - businessErrorValues?: Record - ) { - super(message); - this.status = status; - this.businessErrorCode = businessErrorCode; - this.businessErrorValues = businessErrorValues; - } -} -export function formatMessageValues(properties: Record): Record { - return Object.fromEntries( - Object.entries(properties).map(([key, value]) => [ - key, - typeof value === 'object' && value !== null ? JSON.stringify(value) : String(value), - ]) - ); -} diff --git a/src/utils/types/ProblemDetailError.ts b/src/utils/types/ProblemDetailError.ts index cf62c27f..34b699cf 100644 --- a/src/utils/types/ProblemDetailError.ts +++ b/src/utils/types/ProblemDetailError.ts @@ -4,27 +4,44 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomError } from './CustomError'; -export class ProblemDetailError extends CustomError { +export class ProblemDetailError extends Error { serverName: string; timestamp: Date; traceId: string; + status?: number; + + businessErrorCode?: string; + + businessErrorValues?: Record; + constructor( message: string, serverName: string, timestamp: Date, traceId: string, - status: number, + status?: number, businessErrorCode?: string, businessErrorValues?: Record ) { - super(message, status, businessErrorCode, businessErrorValues); + super(message); this.serverName = serverName; this.timestamp = timestamp; this.traceId = traceId; + this.status = status; + this.businessErrorCode = businessErrorCode; + this.businessErrorValues = businessErrorValues; } } + +export function formatMessageValues(properties: Record): Record { + return Object.fromEntries( + Object.entries(properties).map(([key, value]) => [ + key, + typeof value === 'object' && value !== null ? JSON.stringify(value) : String(value), + ]) + ); +} diff --git a/src/utils/types/index.ts b/src/utils/types/index.ts index ec7b3f2d..47ef2b00 100644 --- a/src/utils/types/index.ts +++ b/src/utils/types/index.ts @@ -4,7 +4,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -export * from './CustomError'; export * from './ProblemDetailError'; export * from './NetworkTimeoutError'; export * from './elementType'; From 5385f56d5fa032370f6f8eaaca6030c2fb60f68d Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Thu, 15 Jan 2026 16:33:29 +0100 Subject: [PATCH 02/10] Rename exceptions --- src/translations/en/businessErrorsEn.ts | 12 ++++++------ src/translations/fr/businessErrorsFr.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/translations/en/businessErrorsEn.ts b/src/translations/en/businessErrorsEn.ts index 694620bc..c513a10c 100644 --- a/src/translations/en/businessErrorsEn.ts +++ b/src/translations/en/businessErrorsEn.ts @@ -66,12 +66,12 @@ export const businessErrorsEn = { 'Only last rule can have empty filter: type {equipmentType}, rule index {index}.', 'sensitivityAnalysis.tooManyFactors': 'Too many factors to run sensitivity analysis: {resultCount} results (limit: {resultCountLimit}) and {variableCount} variables (limit: {variableCountLimit}).', - 'singleLineDiagram.equipmentNotFound': 'Voltage level or substation {id} not found', - 'singleLineDiagram.maxVoltageLevelDisplayed': + 'diagram.equipmentNotFound': 'Voltage level or substation {id} not found', + 'diagram.maxVoltageLevelDisplayed': 'You need to reduce the number of voltage levels to be displayed in the network area diagram (current {nbVoltageLevels}, maximum {maxVoltageLevels})', - 'singleLineDiagram.invalidConfigRequest': "Given sld display mode '{sldDisplayMode}' doesn't exist", - 'singleLineDiagram.invalidEquipment': + 'diagram.invalidConfigRequest': "Given sld display mode '{sldDisplayMode}' doesn't exist", + 'diagram.invalidEquipment': "Given equipment '{id}' of type '{equipmentType}' is not a substation or voltage level id in given network", - 'singleLineDiagram.invalidSubstationLayout': "Mode d'affichage de site '{substationLayout}' invalide", - 'singleLineDiagram.noVoltageLevelIdProvided': 'Aucun poste trouvé', + 'diagram.invalidSubstationLayout': "Mode d'affichage de site '{substationLayout}' invalide", + 'diagram.noVoltageLevelIdProvided': 'Aucun poste trouvé', }; diff --git a/src/translations/fr/businessErrorsFr.ts b/src/translations/fr/businessErrorsFr.ts index b7b2776d..8f6f0c0a 100644 --- a/src/translations/fr/businessErrorsFr.ts +++ b/src/translations/fr/businessErrorsFr.ts @@ -67,13 +67,13 @@ export const businessErrorsFr = { 'Seule la dernière règle peut avoir un filtre vide : type {equipmentType}, indice de la règle : {index}.', 'sensitivityAnalysis.tooManyFactors': 'Trop de facteurs pour exécuter l’analyse de sensibilité : {resultCount} résultats (limite : {resultCountLimit}) et {variableCount} variables (limite : {variableCountLimit}).', - 'singleLineDiagram.equipmentNotFound': 'Voltage level or substation {id} not found', - 'singleLineDiagram.maxVoltageLevelDisplayed': + 'diagram.equipmentNotFound': 'Voltage level or substation {id} not found', + 'diagram.maxVoltageLevelDisplayed': "Vous devez réduire le nombre de postes à afficher dans l'image nodale de zone (nombre actuel {nbVoltageLevels}, nombre maximum {maxVoltageLevels})", - 'singleLineDiagram.invalidConfigRequest': + 'diagram.invalidConfigRequest': "Le mode d'affichage de schéma unifilaire '{sldDisplayMode}' n'existe pas", - 'singleLineDiagram.invalidEquipment': + 'diagram.invalidEquipment': "L'équipement '{id}' de type '{equipmentType}' n'est pas un site ou poste dans le réseau courant", - 'singleLineDiagram.invalidSubstationLayout': "Substation layout '{substationLayout}' incorrect", - 'singleLineDiagram.noVoltageLevelIdProvided': 'No voltage level was found', + 'diagram.invalidSubstationLayout': "Substation layout '{substationLayout}' incorrect", + 'diagram.noVoltageLevelIdProvided': 'No voltage level was found', }; From 0b207dbc9977be9e307f3baab887ef901bce84a1 Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Thu, 15 Jan 2026 16:38:10 +0100 Subject: [PATCH 03/10] Fix locales --- src/translations/en/businessErrorsEn.ts | 4 ++-- src/translations/fr/businessErrorsFr.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/translations/en/businessErrorsEn.ts b/src/translations/en/businessErrorsEn.ts index c513a10c..24ee8cd6 100644 --- a/src/translations/en/businessErrorsEn.ts +++ b/src/translations/en/businessErrorsEn.ts @@ -72,6 +72,6 @@ export const businessErrorsEn = { 'diagram.invalidConfigRequest': "Given sld display mode '{sldDisplayMode}' doesn't exist", 'diagram.invalidEquipment': "Given equipment '{id}' of type '{equipmentType}' is not a substation or voltage level id in given network", - 'diagram.invalidSubstationLayout': "Mode d'affichage de site '{substationLayout}' invalide", - 'diagram.noVoltageLevelIdProvided': 'Aucun poste trouvé', + 'diagram.invalidSubstationLayout': "Substation layout '{substationLayout}' incorrect", + 'diagram.noVoltageLevelIdProvided': 'No voltage level was found', }; diff --git a/src/translations/fr/businessErrorsFr.ts b/src/translations/fr/businessErrorsFr.ts index 8f6f0c0a..71accd63 100644 --- a/src/translations/fr/businessErrorsFr.ts +++ b/src/translations/fr/businessErrorsFr.ts @@ -67,13 +67,13 @@ export const businessErrorsFr = { 'Seule la dernière règle peut avoir un filtre vide : type {equipmentType}, indice de la règle : {index}.', 'sensitivityAnalysis.tooManyFactors': 'Trop de facteurs pour exécuter l’analyse de sensibilité : {resultCount} résultats (limite : {resultCountLimit}) et {variableCount} variables (limite : {variableCountLimit}).', - 'diagram.equipmentNotFound': 'Voltage level or substation {id} not found', + 'diagram.equipmentNotFound': "Poste ou site '{id}' non trouvé", 'diagram.maxVoltageLevelDisplayed': "Vous devez réduire le nombre de postes à afficher dans l'image nodale de zone (nombre actuel {nbVoltageLevels}, nombre maximum {maxVoltageLevels})", 'diagram.invalidConfigRequest': "Le mode d'affichage de schéma unifilaire '{sldDisplayMode}' n'existe pas", 'diagram.invalidEquipment': "L'équipement '{id}' de type '{equipmentType}' n'est pas un site ou poste dans le réseau courant", - 'diagram.invalidSubstationLayout': "Substation layout '{substationLayout}' incorrect", - 'diagram.noVoltageLevelIdProvided': 'No voltage level was found', + 'diagram.invalidSubstationLayout': "Mode d'affichage de site '{substationLayout}' invalide", + 'diagram.noVoltageLevelIdProvided': 'Aucun poste trouvé', }; From dd8b2eea33bf5b95abdb52d0b914db3b5801fde2 Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Thu, 15 Jan 2026 16:58:13 +0100 Subject: [PATCH 04/10] Prettier --- src/translations/fr/businessErrorsFr.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/translations/fr/businessErrorsFr.ts b/src/translations/fr/businessErrorsFr.ts index 71accd63..b60830e3 100644 --- a/src/translations/fr/businessErrorsFr.ts +++ b/src/translations/fr/businessErrorsFr.ts @@ -70,8 +70,7 @@ export const businessErrorsFr = { 'diagram.equipmentNotFound': "Poste ou site '{id}' non trouvé", 'diagram.maxVoltageLevelDisplayed': "Vous devez réduire le nombre de postes à afficher dans l'image nodale de zone (nombre actuel {nbVoltageLevels}, nombre maximum {maxVoltageLevels})", - 'diagram.invalidConfigRequest': - "Le mode d'affichage de schéma unifilaire '{sldDisplayMode}' n'existe pas", + 'diagram.invalidConfigRequest': "Le mode d'affichage de schéma unifilaire '{sldDisplayMode}' n'existe pas", 'diagram.invalidEquipment': "L'équipement '{id}' de type '{equipmentType}' n'est pas un site ou poste dans le réseau courant", 'diagram.invalidSubstationLayout': "Mode d'affichage de site '{substationLayout}' invalide", From 63d50d04dd974e19768487915533e3b64dc4826f Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Mon, 19 Jan 2026 10:56:24 +0100 Subject: [PATCH 05/10] Update error message --- src/translations/en/businessErrorsEn.ts | 2 +- src/translations/fr/businessErrorsFr.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/translations/en/businessErrorsEn.ts b/src/translations/en/businessErrorsEn.ts index 24ee8cd6..4ec3294e 100644 --- a/src/translations/en/businessErrorsEn.ts +++ b/src/translations/en/businessErrorsEn.ts @@ -73,5 +73,5 @@ export const businessErrorsEn = { 'diagram.invalidEquipment': "Given equipment '{id}' of type '{equipmentType}' is not a substation or voltage level id in given network", 'diagram.invalidSubstationLayout': "Substation layout '{substationLayout}' incorrect", - 'diagram.noVoltageLevelIdProvided': 'No voltage level was found', + 'diagram.noVoltageLevelIdProvided': 'No voltage level was provided to the NAD generation input', }; diff --git a/src/translations/fr/businessErrorsFr.ts b/src/translations/fr/businessErrorsFr.ts index b60830e3..1004f1e5 100644 --- a/src/translations/fr/businessErrorsFr.ts +++ b/src/translations/fr/businessErrorsFr.ts @@ -74,5 +74,5 @@ export const businessErrorsFr = { 'diagram.invalidEquipment': "L'équipement '{id}' de type '{equipmentType}' n'est pas un site ou poste dans le réseau courant", 'diagram.invalidSubstationLayout': "Mode d'affichage de site '{substationLayout}' invalide", - 'diagram.noVoltageLevelIdProvided': 'Aucun poste trouvé', + 'diagram.noVoltageLevelIdProvided': "Aucun poste n'a été fourni en entrée de la génération de NAD", }; From efc5c78a20454ae4245198246710f17979fa505c Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Tue, 20 Jan 2026 14:58:31 +0100 Subject: [PATCH 06/10] Add invalid csv locale --- src/translations/en/businessErrorsEn.ts | 1 + src/translations/fr/businessErrorsFr.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/translations/en/businessErrorsEn.ts b/src/translations/en/businessErrorsEn.ts index 4ec3294e..dba56b8b 100644 --- a/src/translations/en/businessErrorsEn.ts +++ b/src/translations/en/businessErrorsEn.ts @@ -73,5 +73,6 @@ export const businessErrorsEn = { 'diagram.invalidEquipment': "Given equipment '{id}' of type '{equipmentType}' is not a substation or voltage level id in given network", 'diagram.invalidSubstationLayout': "Substation layout '{substationLayout}' incorrect", + 'diagram.invalidCsv': 'Provided CSV is invalid', 'diagram.noVoltageLevelIdProvided': 'No voltage level was provided to the NAD generation input', }; diff --git a/src/translations/fr/businessErrorsFr.ts b/src/translations/fr/businessErrorsFr.ts index 1004f1e5..1025232c 100644 --- a/src/translations/fr/businessErrorsFr.ts +++ b/src/translations/fr/businessErrorsFr.ts @@ -74,5 +74,6 @@ export const businessErrorsFr = { 'diagram.invalidEquipment': "L'équipement '{id}' de type '{equipmentType}' n'est pas un site ou poste dans le réseau courant", 'diagram.invalidSubstationLayout': "Mode d'affichage de site '{substationLayout}' invalide", + 'diagram.invalidCsv': 'Le CSV fourni est invalide', 'diagram.noVoltageLevelIdProvided': "Aucun poste n'a été fourni en entrée de la génération de NAD", }; From d5f6dbb7f4c3b358c75c8e79bfcac53d131a8dc3 Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Wed, 21 Jan 2026 10:21:23 +0100 Subject: [PATCH 07/10] Add no configured position error locale --- src/translations/en/businessErrorsEn.ts | 1 + src/translations/fr/businessErrorsFr.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/translations/en/businessErrorsEn.ts b/src/translations/en/businessErrorsEn.ts index dba56b8b..2b3bd330 100644 --- a/src/translations/en/businessErrorsEn.ts +++ b/src/translations/en/businessErrorsEn.ts @@ -75,4 +75,5 @@ export const businessErrorsEn = { 'diagram.invalidSubstationLayout': "Substation layout '{substationLayout}' incorrect", 'diagram.invalidCsv': 'Provided CSV is invalid', 'diagram.noVoltageLevelIdProvided': 'No voltage level was provided to the NAD generation input', + 'diagram.noConfiguredPosition': 'No configured position has been found', }; diff --git a/src/translations/fr/businessErrorsFr.ts b/src/translations/fr/businessErrorsFr.ts index 1025232c..b1c505de 100644 --- a/src/translations/fr/businessErrorsFr.ts +++ b/src/translations/fr/businessErrorsFr.ts @@ -76,4 +76,5 @@ export const businessErrorsFr = { 'diagram.invalidSubstationLayout': "Mode d'affichage de site '{substationLayout}' invalide", 'diagram.invalidCsv': 'Le CSV fourni est invalide', 'diagram.noVoltageLevelIdProvided': "Aucun poste n'a été fourni en entrée de la génération de NAD", + 'diagram.noConfiguredPosition': "Aucune position configurée n'a été trouvée", }; From d8cf6f6dded43b5a7c517e8136bbd9b3c16787d9 Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Wed, 21 Jan 2026 16:06:57 +0100 Subject: [PATCH 08/10] Restore custom error export --- src/utils/types/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/types/index.ts b/src/utils/types/index.ts index 47ef2b00..ec7b3f2d 100644 --- a/src/utils/types/index.ts +++ b/src/utils/types/index.ts @@ -4,6 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +export * from './CustomError'; export * from './ProblemDetailError'; export * from './NetworkTimeoutError'; export * from './elementType'; From e0d691316be068e7f80feb09ae3e4e50a3ca29d6 Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Wed, 28 Jan 2026 11:13:45 +0100 Subject: [PATCH 09/10] Lint --- src/translations/en/businessErrorsEn.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/translations/en/businessErrorsEn.ts b/src/translations/en/businessErrorsEn.ts index f690e3b8..846d492d 100644 --- a/src/translations/en/businessErrorsEn.ts +++ b/src/translations/en/businessErrorsEn.ts @@ -71,7 +71,7 @@ export const businessErrorsEn = { 'Only last rule can have empty filter: type {equipmentType}, rule index {index}.', 'sensitivityAnalysis.tooManyFactors': 'Too many factors to run sensitivity analysis: {resultCount} results (limit: {resultCountLimit}) and {variableCount} variables (limit: {variableCountLimit}).', - 'pccMin.missingFilter': 'The configuration contains one filter that has been deleted.', + 'pccMin.missingFilter': 'The configuration contains one filter that has been deleted.', 'diagram.equipmentNotFound': 'Voltage level or substation {id} not found', 'diagram.maxVoltageLevelDisplayed': 'You need to reduce the number of voltage levels to be displayed in the network area diagram (current {nbVoltageLevels}, maximum {maxVoltageLevels})', From 0d9f934d697340c6747dc1fcba1e2d66a9757cbc Mon Sep 17 00:00:00 2001 From: Slimane AMAR Date: Wed, 11 Feb 2026 19:15:22 +0100 Subject: [PATCH 10/10] Review --- src/translations/en/businessErrorsEn.ts | 15 +++++++-------- src/translations/fr/businessErrorsFr.ts | 15 +++++++-------- src/utils/types/types.ts | 7 +++---- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/translations/en/businessErrorsEn.ts b/src/translations/en/businessErrorsEn.ts index 67d00043..5fdcd014 100644 --- a/src/translations/en/businessErrorsEn.ts +++ b/src/translations/en/businessErrorsEn.ts @@ -72,14 +72,13 @@ export const businessErrorsEn = { 'sensitivityAnalysis.tooManyFactors': 'Too many factors to run sensitivity analysis: {resultCount} results (limit: {resultCountLimit}) and {variableCount} variables (limit: {variableCountLimit}).', 'pccMin.missingFilter': 'The configuration contains one filter that has been deleted.', - 'diagram.equipmentNotFound': 'Voltage level or substation {id} not found', + 'diagram.invalidEquipmentType': + "The equipment {id} of type {equipmentType} is not a substation or voltage level in given network", + 'diagram.invalidSubstationLayout': "Given substation layout {substationLayout} doesn't exist", + 'diagram.invalidDisplayMode': "Given sld display mode {sldDisplayMode} doesn't exist", 'diagram.maxVoltageLevelDisplayed': 'You need to reduce the number of voltage levels to be displayed in the network area diagram (current {nbVoltageLevels}, maximum {maxVoltageLevels})', - 'diagram.invalidConfigRequest': "Given sld display mode '{sldDisplayMode}' doesn't exist", - 'diagram.invalidEquipment': - "Given equipment '{id}' of type '{equipmentType}' is not a substation or voltage level id in given network", - 'diagram.invalidSubstationLayout': "Substation layout '{substationLayout}' incorrect", - 'diagram.invalidCsv': 'Provided CSV is invalid', - 'diagram.noVoltageLevelIdProvided': 'No voltage level was provided to the NAD generation input', - 'diagram.noConfiguredPosition': 'No configured position has been found', + 'diagram.equipmentNotFound': 'Voltage level or substation {id} not found', + 'diagram.noConfiguredPosition': 'No configured position found', + 'diagram.noVoltageLevelFound': 'No voltage level found for this network area diagram', }; diff --git a/src/translations/fr/businessErrorsFr.ts b/src/translations/fr/businessErrorsFr.ts index 75b1ad90..7396f646 100644 --- a/src/translations/fr/businessErrorsFr.ts +++ b/src/translations/fr/businessErrorsFr.ts @@ -73,14 +73,13 @@ export const businessErrorsFr = { 'sensitivityAnalysis.tooManyFactors': 'Trop de facteurs pour exécuter l’analyse de sensibilité : {resultCount} résultats (limite : {resultCountLimit}) et {variableCount} variables (limite : {variableCountLimit}).', 'pccMin.missingFilter': 'La configuration contient un filtre qui a été supprimé.', - 'diagram.equipmentNotFound': "Poste ou site '{id}' non trouvé", + 'diagram.invalidEquipmentType': + "L'équipement {id} de type {equipmentType} n'est pas un site ou poste dans le réseau courant", + 'diagram.invalidSubstationLayout': "Le mode d'affichage de site {substationLayout} n'existe pas", + 'diagram.invalidDisplayMode': "Le mode d'affichage de schéma unifilaire {sldDisplayMode} n'existe pas", 'diagram.maxVoltageLevelDisplayed': "Vous devez réduire le nombre de postes à afficher dans l'image nodale de zone (nombre actuel {nbVoltageLevels}, nombre maximum {maxVoltageLevels})", - 'diagram.invalidConfigRequest': "Le mode d'affichage de schéma unifilaire '{sldDisplayMode}' n'existe pas", - 'diagram.invalidEquipment': - "L'équipement '{id}' de type '{equipmentType}' n'est pas un site ou poste dans le réseau courant", - 'diagram.invalidSubstationLayout': "Mode d'affichage de site '{substationLayout}' invalide", - 'diagram.invalidCsv': 'Le CSV fourni est invalide', - 'diagram.noVoltageLevelIdProvided': "Aucun poste n'a été fourni en entrée de la génération de NAD", - 'diagram.noConfiguredPosition': "Aucune position configurée n'a été trouvée", + 'diagram.equipmentNotFound': 'Poste ou site {id} non trouvé', + 'diagram.noConfiguredPosition': 'Aucune position configurée trouvée', + 'diagram.noVoltageLevelFound': 'Aucun poste trouvé pour cette image nodale de zone', }; diff --git a/src/utils/types/types.ts b/src/utils/types/types.ts index ebf10549..c1c2a715 100644 --- a/src/utils/types/types.ts +++ b/src/utils/types/types.ts @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import type { UUID } from 'node:crypto'; -import { IntlShape } from 'react-intl'; +import { MessageDescriptor, PrimitiveType } from 'react-intl'; import { ElementType } from './elementType'; export type Input = string | number; @@ -79,10 +79,9 @@ export enum ArrayAction { REMOVE = 'REMOVE', } -// extracted from intl .d.ts but the type is not explicitely defined and exported -export type FormatValues = Parameters[1]; +export type FormatValues = Record; export type ErrorMessageDescriptor = { - descriptor: Parameters[0]; + descriptor: MessageDescriptor; values?: FormatValues; };