fix: ensure id tags cache is properly cleaned
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / OCPPIncomingRequestService.ts
index 1206cede00d0493df941f54e73dc03cffedfc28c..390feda8fbc6f7930964e884bddbf0061ec8ada5 100644 (file)
@@ -15,7 +15,7 @@ import type {
   JsonType,
   OCPPVersion,
 } from '../../types';
-import { ErrorUtils, logger } from '../../utils';
+import { logger, setDefaultErrorParams } from '../../utils';
 
 const moduleName = 'OCPPIncomingRequestService';
 
@@ -62,7 +62,7 @@ export abstract class OCPPIncomingRequestService extends AsyncResource {
     error: Error,
     params: HandleErrorParams<T> = { throwError: true, consoleOut: false }
   ): T | undefined {
-    ErrorUtils.handleErrorParams(params);
+    setDefaultErrorParams(params);
     logger.error(
       `${chargingStation.logPrefix()} ${moduleName}.handleIncomingRequestError: Incoming request command '${commandName}' error:`,
       error
@@ -104,10 +104,14 @@ export abstract class OCPPIncomingRequestService extends AsyncResource {
   }
 
   protected handleRequestClearCache(chargingStation: ChargingStation): ClearCacheResponse {
-    chargingStation.idTagsCache.deleteIdTags(
-      ChargingStationUtils.getIdTagsFile(chargingStation.stationInfo)
-    );
-    return OCPPConstants.OCPP_RESPONSE_ACCEPTED;
+    if (
+      chargingStation.idTagsCache.deleteIdTags(
+        ChargingStationUtils.getIdTagsFile(chargingStation.stationInfo)
+      )
+    ) {
+      return OCPPConstants.OCPP_RESPONSE_ACCEPTED;
+    }
+    return OCPPConstants.OCPP_RESPONSE_REJECTED;
   }
 
   public abstract incomingRequestHandler(