From: Jérôme Benoit Date: Thu, 30 Nov 2023 16:51:19 +0000 (+0100) Subject: fix: handle not found hashId in UI server X-Git-Tag: v1.2.28~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f12cf7ef207d1e1b243c45b1eecf5d89d8ec772d;p=e-mobility-charging-stations-simulator.git fix: handle not found hashId in UI server Signed-off-by: Jérôme Benoit --- 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