From 2d8cee5a8b6816947f4455ef53e088572c5b1671 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 19 May 2020 14:22:46 +0200 Subject: [PATCH] Give more informations on JSON parsing error. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/charging-station/ChargingStation.js b/src/charging-station/ChargingStation.js index 99532afa..6b9bfc2a 100644 --- a/src/charging-station/ChargingStation.js +++ b/src/charging-station/ChargingStation.js @@ -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 -- 2.34.1