From: Jérôme Benoit Date: Fri, 7 Jun 2024 19:43:20 +0000 (+0200) Subject: fix: add sanity check in ATG on connector id X-Git-Tag: v1.3.5~10 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a4d9680730c77debfb3b9455e4bd5b63e61ce664;p=e-mobility-charging-stations-simulator.git fix: add sanity check in ATG on connector id Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 83cf259a..0eb47381 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -408,6 +408,10 @@ export class AutomaticTransactionGenerator { private getConnectorStatus (connectorId: number): Status { const statusIndex = connectorId - 1 + if (statusIndex < 0) { + logger.error(`${this.logPrefix(connectorId)} invalid connector id`) + throw new BaseError(`Invalid connector id ${connectorId}`) + } let connectorStatus: Status | undefined if (this.chargingStation.getAutomaticTransactionGeneratorStatuses()?.[statusIndex] != null) { connectorStatus = clone(