Give more informations on JSON parsing error.
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 19 May 2020 12:22:46 +0000 (14:22 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 19 May 2020 12:22:46 +0000 (14:22 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.js

index 99532afa59026884efa704bb04ba1612be5a57ca..6b9bfc2aa983e923e0ce175d6fd0ff725b0ff159 100644 (file)
@@ -180,10 +180,11 @@ class ChargingStation {
   }
 
   async onMessage(message) {
-    // Parse the message
-    const [messageType, messageId, commandName, commandPayload, errorDetails] = JSON.parse(message);
-
+    let [messageType, messageId, commandName, commandPayload, errorDetails] = [0, '', Constants.ENTITY_CHARGING_STATION, '', ''];
     try {
+      // Parse the message
+      [messageType, messageId, commandName, commandPayload, errorDetails] = JSON.parse(message);
+
       // Check the Type of message
       switch (messageType) {
         // Incoming Message