X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPRequestService.ts;h=68338670aa1c4dd710ec1310568328e7d13dd198;hb=e6159ce8b782e3464a9a0dc377897bc4a4718121;hp=625e69f99bc025f89b8459418aa32f5c8d52b463;hpb=e909d2a71e82122e970db9d6f262bd1415a3bb20;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 625e69f9..68338670 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -37,6 +37,7 @@ export default abstract class OCPPRequestService { this.ajv = new Ajv(); ajvFormats(this.ajv); this.requestHandler.bind(this); + this.sendMessage.bind(this); this.sendResponse.bind(this); this.sendError.bind(this); this.internalSendMessage.bind(this); @@ -70,7 +71,9 @@ export default abstract class OCPPRequestService { commandName ); } catch (error) { - this.handleRequestError(chargingStation, commandName, error as Error); + this.handleSendMessageError(chargingStation, commandName, error as Error, { + throwError: true, + }); } } @@ -90,7 +93,7 @@ export default abstract class OCPPRequestService { commandName ); } catch (error) { - this.handleRequestError(chargingStation, commandName, error as Error); + this.handleSendMessageError(chargingStation, commandName, error as Error); } } @@ -114,7 +117,7 @@ export default abstract class OCPPRequestService { params ); } catch (error) { - this.handleRequestError(chargingStation, commandName, error as Error, { throwError: false }); + this.handleSendMessageError(chargingStation, commandName, error as Error); } } @@ -356,14 +359,14 @@ export default abstract class OCPPRequestService { } } - private handleRequestError( + private handleSendMessageError( chargingStation: ChargingStation, commandName: RequestCommand | IncomingRequestCommand, error: Error, - params: HandleErrorParams = { throwError: true } + params: HandleErrorParams = { throwError: false } ): void { logger.error(`${chargingStation.logPrefix()} Request command '${commandName}' error:`, error); - if (params?.throwError) { + if (params?.throwError === true) { throw error; } }