X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2F1.6%2FOCCP16IncomingRequestService.ts;h=6b8443520490718cd4075e5fcb420b9f2f2324ee;hb=193d2c0a14e09db6af0a618525f8e0c8aef58cfe;hp=5a41771d57ca0c4c9638acacfaed5d28a1420a2f;hpb=035742f7433c00edbd0259966e7af6a1cfa2f0a1;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts index 5a41771d..6b844352 100644 --- a/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts @@ -17,11 +17,12 @@ import logger from '../../../utils/Logger'; export default class OCPP16IncomingRequestService extends OCPPIncomingRequestService { public async handleRequest(messageId: string, commandName: OCPP16IncomingRequestCommand, commandPayload: Record): Promise { let response; + const methodName = `handleRequest${commandName}`; // Call - if (typeof this['handleRequest' + commandName] === 'function') { + if (typeof this[methodName] === 'function') { try { // Call the method to build the response - response = await this['handleRequest' + commandName](commandPayload); + response = await this[methodName](commandPayload); } catch (error) { // Log logger.error(this.chargingStation.logPrefix() + ' Handle request error: %j', error);