]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor: use try/catch instead of .catch() for stopMessageSequence error handling
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 24 Mar 2026 21:21:21 +0000 (22:21 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 24 Mar 2026 21:21:21 +0000 (22:21 +0100)
src/charging-station/ChargingStation.ts

index c856ae29480612786429ba3f05ca1e37205a3ef1..605f77fcd40f7abef1cefba8c548b6b9e5becad9 100644 (file)
@@ -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) {