Ensure OCPP error messages always follow the OCPP specs
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 29 Jun 2020 19:24:52 +0000 (21:24 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 29 Jun 2020 19:24:52 +0000 (21:24 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.js

index 6b9bfc2aa983e923e0ce175d6fd0ff725b0ff159..7315f73f98e6c7fcef257ceeaa1854d0d3f93495 100644 (file)
@@ -299,14 +299,8 @@ class ChargingStation {
         // Error Message
         case Constants.OCPP_JSON_CALL_ERROR_MESSAGE:
           // Build Message
-          // eslint-disable-next-line no-case-declarations
-          const {
-            code,
-            message,
-            details,
-          } = command;
-          this._statistics.addMessage(`Error ${code}`);
-          messageToSend = JSON.stringify([messageType, messageId, code, message, details]);
+          this._statistics.addMessage(`Error ${command.code}`);
+          messageToSend = JSON.stringify([messageType, messageId, command.code ? command.code : Constants.OCPP_ERROR_GENERIC_ERROR, command.message ? command.message : '', command.details ? command.details : {}]);
           break;
       }
       // Check if wsConnection in ready