From: Jérôme Benoit Date: Mon, 29 Jun 2020 19:24:52 +0000 (+0200) Subject: Ensure OCPP error messages always follow the OCPP specs X-Git-Tag: v1.0.1-0~317 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=894a1780a9aeabd574529e2c80be3b7aa884b93c;p=e-mobility-charging-stations-simulator.git Ensure OCPP error messages always follow the OCPP specs Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.js b/src/charging-station/ChargingStation.js index 6b9bfc2a..7315f73f 100644 --- a/src/charging-station/ChargingStation.js +++ b/src/charging-station/ChargingStation.js @@ -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