Fix error handling at OCPP message sending
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 15 Sep 2022 08:40:40 +0000 (10:40 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 15 Sep 2022 08:40:40 +0000 (10:40 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/OCPPRequestService.ts

index 653679e9b9e5b3452bcf508dc8a2be886022ff51..921945e82cdea1bb92bee6373092151d12f8771c 100644 (file)
@@ -71,7 +71,7 @@ export default abstract class OCPPRequestService {
       );
     } catch (error) {
       this.handleSendMessageError(chargingStation, commandName, error as Error, {
-        throwError: false,
+        throwError: true,
       });
     }
   }
@@ -116,9 +116,7 @@ export default abstract class OCPPRequestService {
         params
       );
     } catch (error) {
-      this.handleSendMessageError(chargingStation, commandName, error as Error, {
-        throwError: false,
-      });
+      this.handleSendMessageError(chargingStation, commandName, error as Error);
     }
   }
 
@@ -364,10 +362,10 @@ export default abstract class OCPPRequestService {
     chargingStation: ChargingStation,
     commandName: RequestCommand | IncomingRequestCommand,
     error: Error,
-    params: HandleErrorParams<EmptyObject> = { throwError: true }
+    params: HandleErrorParams<EmptyObject> = { throwError: false }
   ): void {
     logger.error(`${chargingStation.logPrefix()} Request command '${commandName}' error:`, error);
-    if (params?.throwError) {
+    if (params?.throwError === true) {
       throw error;
     }
   }