From: Jérôme Benoit Date: Sat, 2 Oct 2021 09:03:37 +0000 (+0200) Subject: Improve resquest response error logging X-Git-Tag: v1.1.22~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=887fef764941b7a9970fd78bbc608882c320fe78;p=e-mobility-charging-stations-simulator.git Improve resquest response error logging Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 5609fe21..94f98e8b 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -59,7 +59,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer } } else { // Throw exception - throw new OCPPError(ErrorType.NOT_IMPLEMENTED, `${commandName} is not implemented to handle payload ${JSON.stringify(commandPayload, null, 2)}`, commandName); + throw new OCPPError(ErrorType.NOT_IMPLEMENTED, `${commandName} is not implemented to handle request payload ${JSON.stringify(commandPayload, null, 2)}`, commandName); } // Send the built response await this.chargingStation.ocppRequestService.sendMessage(messageId, response, MessageType.CALL_RESULT_MESSAGE, commandName); diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 77c7b77a..cc334aee 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -32,9 +32,13 @@ export default class OCPP16ResponseService extends OCPPResponseService { public async handleResponse(commandName: OCPP16RequestCommand, payload: Record | string, requestPayload: Record): Promise { if (this.responseHandlers.has(commandName)) { - await this.responseHandlers.get(commandName)(payload, requestPayload); + try { + await this.responseHandlers.get(commandName)(payload, requestPayload); + } catch (error) { + logger.error(this.chargingStation.logPrefix() + ' Handle request response error: %j', error); + } } else { - logger.error(this.chargingStation.logPrefix() + ' Trying to call an undefined method for command ' + commandName + ' response'); + logger.error(`${this.chargingStation.logPrefix()} %s is not implemented to handle request response payload %j`, commandName, payload); } }