Improve OCPP stack error messages
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 28 Sep 2021 07:06:57 +0000 (09:06 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 28 Sep 2021 07:06:57 +0000 (09:06 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/charging-station/ChargingStation.ts
src/charging-station/ocpp/OCPPRequestService.ts

index b035e5b3dc297ca239e0df7fc80bd87848962a5e..f93f4133bccfbd68cda6297284f4f22a96b418fe 100644 (file)
@@ -679,11 +679,11 @@ export default class ChargingStation {
           if (Utils.isIterable(cachedRequest)) {
             [responseCallback, , , requestPayload] = cachedRequest;
           } else {
-            throw new OCPPError(ErrorType.PROTOCOL_ERROR, `Response request for message id ${messageId} is not iterable`, commandName);
+            throw new OCPPError(ErrorType.PROTOCOL_ERROR, `Cached request for message id ${messageId} response is not iterable`, commandName);
           }
           if (!responseCallback) {
             // Error
-            throw new OCPPError(ErrorType.INTERNAL_ERROR, `Response request for unknown message id ${messageId}`, commandName);
+            throw new OCPPError(ErrorType.INTERNAL_ERROR, `Response for unknown message id ${messageId}`, commandName);
           }
           responseCallback(commandName, requestPayload);
           break;
@@ -693,11 +693,11 @@ export default class ChargingStation {
           if (Utils.isIterable(cachedRequest)) {
             [, rejectCallback, requestCommandName] = cachedRequest;
           } else {
-            throw new OCPPError(ErrorType.PROTOCOL_ERROR, `Error request for message id ${messageId} is not iterable`);
+            throw new OCPPError(ErrorType.PROTOCOL_ERROR, `Cached request for message id ${messageId} error response is not iterable`);
           }
           if (!rejectCallback) {
             // Error
-            throw new OCPPError(ErrorType.INTERNAL_ERROR, `Error request for unknown message id ${messageId}`, requestCommandName);
+            throw new OCPPError(ErrorType.INTERNAL_ERROR, `Error response for unknown message id ${messageId}`, requestCommandName);
           }
           rejectCallback(new OCPPError(commandName, commandPayload.toString(), requestCommandName, errorDetails));
           break;
@@ -709,7 +709,7 @@ export default class ChargingStation {
       }
     } catch (error) {
       // Log
-      logger.error('%s Incoming request message %j matching cached request %j processing error %j ', this.logPrefix(), data, this.requests.get(messageId), error);
+      logger.error('%s Incoming OCPP message %j matching cached request %j processing error %j', this.logPrefix(), data, this.requests.get(messageId), error);
       // Send error
       messageType === MessageType.CALL_MESSAGE && await this.ocppRequestService.sendError(messageId, error, commandName);
     }
index 444e5fc67965081cc8a3b3a24c64b9c52ae9e4b8..43e4102578eaceb44222d71e78485ce73a9e0628 100644 (file)
@@ -79,7 +79,7 @@ export default abstract class OCPPRequestService {
         if (self.chargingStation.getEnableStatistics()) {
           self.chargingStation.performanceStatistics.addRequestStatistic(commandName, MessageType.CALL_ERROR_MESSAGE);
         }
-        logger.debug(`${self.chargingStation.logPrefix()} Error %j occurred when calling command %s with parameters %j`, error, commandName, commandParams);
+        logger.error(`${self.chargingStation.logPrefix()} Error %j occurred when calling command %s with parameters %j`, error, commandName, commandParams);
         self.chargingStation.requests.delete(messageId);
         reject(error);
       }