From f12cf7ef207d1e1b243c45b1eecf5d89d8ec772d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 30 Nov 2023 17:51:19 +0100 Subject: [PATCH] fix: handle not found hashId in UI server MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../ui-services/AbstractUIService.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/charging-station/ui-server/ui-services/AbstractUIService.ts b/src/charging-station/ui-server/ui-services/AbstractUIService.ts index a190b603..d7595c26 100644 --- a/src/charging-station/ui-server/ui-services/AbstractUIService.ts +++ b/src/charging-station/ui-server/ui-services/AbstractUIService.ts @@ -162,18 +162,21 @@ export abstract class AbstractUIService { ): void { if (isNotEmptyArray(payload.hashIds)) { payload.hashIds = payload.hashIds - ?.filter((hashId) => !isNullOrUndefined(hashId)) ?.map((hashId) => { if (this.uiServer.chargingStations.has(hashId) === true) { return hashId; } - logger.warn( - `${this.logPrefix( - moduleName, - 'sendBroadcastChannelRequest', - )} Charging station with hashId '${hashId}' not found`, - ); - }) as string[]; + const msg = `${this.logPrefix( + moduleName, + 'sendBroadcastChannelRequest', + )} Charging station with hashId '${hashId}' not found`; + if (payload.hashIds?.length === 1) { + throw new BaseError(msg); + } else { + logger.warn(msg); + } + }) + ?.filter((hashId) => !isNullOrUndefined(hashId)) as string[]; } const expectedNumberOfResponses = isNotEmptyArray(payload.hashIds) ? payload.hashIds!.length -- 2.34.1