From: Jérôme Benoit Date: Tue, 24 Mar 2026 21:21:21 +0000 (+0100) Subject: refactor: use try/catch instead of .catch() for stopMessageSequence error handling X-Git-Tag: ocpp-server@v3.4.0~17 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=7519fc32a61bb1077a35e4e8565e2a39fcfebe4c;p=e-mobility-charging-stations-simulator.git refactor: use try/catch instead of .catch() for stopMessageSequence error handling --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index c856ae29..605f77fc 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1153,13 +1153,15 @@ export class ChargingStation extends EventEmitter { if (!this.stopping) { this.stopping = true try { - await promiseWithTimeout( - this.stopMessageSequence(reason, stopTransactions), - Constants.STOP_MESSAGE_SEQUENCE_TIMEOUT, - `Timeout ${formatDurationMilliSeconds(Constants.STOP_MESSAGE_SEQUENCE_TIMEOUT)} reached at stopping message sequence` - ).catch((error: unknown) => { + try { + await promiseWithTimeout( + this.stopMessageSequence(reason, stopTransactions), + Constants.STOP_MESSAGE_SEQUENCE_TIMEOUT, + `Timeout ${formatDurationMilliSeconds(Constants.STOP_MESSAGE_SEQUENCE_TIMEOUT)} reached at stopping message sequence` + ) + } catch (error: unknown) { logger.error(`${this.logPrefix()} Error while stopping message sequence:`, error) - }) + } this.ocppIncomingRequestService.stop(this) this.closeWSConnection() if (this.stationInfo?.enableStatistics === true) {