From: Jérôme Benoit Date: Mon, 29 Jan 2024 17:41:56 +0000 (+0100) Subject: refactor: remove unneeded try {} catch {} X-Git-Tag: v1.2.33~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f2f33b97eb2044a8c715ebe0c0eb1c7b973eb8c4;p=e-mobility-charging-stations-simulator.git refactor: remove unneeded try {} catch {} Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index f09864d4..00926e4f 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -311,7 +311,7 @@ export class Bootstrap extends EventEmitter { break case ChargingStationWorkerMessageEvents.startWorkerElementError: logger.error( - `${this.logPrefix()} ${moduleName}.messageHandler: Error occured while starting worker element:`, + `${this.logPrefix()} ${moduleName}.messageHandler: Error occurred while starting worker element:`, msg.data ) this.emit(ChargingStationWorkerMessageEvents.startWorkerElementError, msg.data) diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 7f932cb0..2af366f9 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -1553,42 +1553,30 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { ) { return OCPP16Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED } - try { - switch (requestedMessage) { - case OCPP16MessageTrigger.BootNotification: - Promise.resolve() - .then(() => - this.emit(`Trigger${OCPP16MessageTrigger.BootNotification}`, chargingStation) - ) - .catch(Constants.EMPTY_FUNCTION) - return OCPP16Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED - case OCPP16MessageTrigger.Heartbeat: - Promise.resolve() - .then(() => this.emit(`Trigger${OCPP16MessageTrigger.Heartbeat}`, chargingStation)) - .catch(Constants.EMPTY_FUNCTION) - return OCPP16Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED - case OCPP16MessageTrigger.StatusNotification: - Promise.resolve() - .then(() => - this.emit( - `Trigger${OCPP16MessageTrigger.StatusNotification}`, - chargingStation, - connectorId - ) + switch (requestedMessage) { + case OCPP16MessageTrigger.BootNotification: + Promise.resolve() + .then(() => this.emit(`Trigger${OCPP16MessageTrigger.BootNotification}`, chargingStation)) + .catch(Constants.EMPTY_FUNCTION) + return OCPP16Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED + case OCPP16MessageTrigger.Heartbeat: + Promise.resolve() + .then(() => this.emit(`Trigger${OCPP16MessageTrigger.Heartbeat}`, chargingStation)) + .catch(Constants.EMPTY_FUNCTION) + return OCPP16Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED + case OCPP16MessageTrigger.StatusNotification: + Promise.resolve() + .then(() => + this.emit( + `Trigger${OCPP16MessageTrigger.StatusNotification}`, + chargingStation, + connectorId ) - .catch(Constants.EMPTY_FUNCTION) - return OCPP16Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED - default: - return OCPP16Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED - } - } catch (error) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - return this.handleIncomingRequestError( - chargingStation, - OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, - error as Error, - { errorResponse: OCPP16Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED } - )! + ) + .catch(Constants.EMPTY_FUNCTION) + return OCPP16Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED + default: + return OCPP16Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED } }