From: Jérôme Benoit Date: Fri, 27 Mar 2026 20:50:43 +0000 (+0100) Subject: refactor: harmonize errMsg → errorMsg for intra-file naming consistency X-Git-Tag: ocpp-server@v4.0.0~22 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e76a841c7e2fce7e9f3151d0507ef94454285e79;p=e-mobility-charging-stations-simulator.git refactor: harmonize errMsg → errorMsg for intra-file naming consistency OCPPServiceUtils.ts used both errMsg (4x) and errorMsg (1x) for the same semantic. PerformanceStatistics.ts used errMsg (4x) while the rest of the codebase uses errorMsg. Align to errorMsg everywhere. --- diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index d9d38c92..c47f8459 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -1253,7 +1253,7 @@ const buildPowerMeasurandValue = ( ) break default: { - const errMsg = `MeterValues measurand ${ + const errorMsg = `MeterValues measurand ${ powerTemplate.measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER // eslint-disable-next-line @typescript-eslint/restrict-template-expressions }: Unknown ${chargingStation.stationInfo?.currentOutType} currentOutType in template file ${ @@ -1261,8 +1261,8 @@ const buildPowerMeasurandValue = ( }, cannot calculate ${ powerTemplate.measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER } measurand value` - logger.error(`${chargingStation.logPrefix()} ${errMsg}`) - throw new OCPPError(ErrorType.INTERNAL_ERROR, errMsg, RequestCommand.METER_VALUES) + logger.error(`${chargingStation.logPrefix()} ${errorMsg}`) + throw new OCPPError(ErrorType.INTERNAL_ERROR, errorMsg, RequestCommand.METER_VALUES) } } @@ -1519,7 +1519,7 @@ const buildCurrentMeasurandValue = ( : getRandomFloatRounded(connectorMaximumAmperage, connectorMinimumAmperage) break default: { - const errMsg = `MeterValues measurand ${ + const errorMsg = `MeterValues measurand ${ currentTemplate.measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER // eslint-disable-next-line @typescript-eslint/restrict-template-expressions }: Unknown ${chargingStation.stationInfo?.currentOutType} currentOutType in template file ${ @@ -1527,8 +1527,8 @@ const buildCurrentMeasurandValue = ( }, cannot calculate ${ currentTemplate.measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER } measurand value` - logger.error(`${chargingStation.logPrefix()} ${errMsg}`) - throw new OCPPError(ErrorType.INTERNAL_ERROR, errMsg, RequestCommand.METER_VALUES) + logger.error(`${chargingStation.logPrefix()} ${errorMsg}`) + throw new OCPPError(ErrorType.INTERNAL_ERROR, errorMsg, RequestCommand.METER_VALUES) } } @@ -1960,17 +1960,17 @@ const checkMeasurandPowerDivider = ( measurandType: MeterValueMeasurand | undefined ): void => { if (chargingStation.powerDivider == null) { - const errMsg = `MeterValues measurand ${ + const errorMsg = `MeterValues measurand ${ measurandType ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER }: powerDivider is undefined` - logger.error(`${chargingStation.logPrefix()} ${errMsg}`) - throw new OCPPError(ErrorType.INTERNAL_ERROR, errMsg, RequestCommand.METER_VALUES) + logger.error(`${chargingStation.logPrefix()} ${errorMsg}`) + throw new OCPPError(ErrorType.INTERNAL_ERROR, errorMsg, RequestCommand.METER_VALUES) } else if (chargingStation.powerDivider <= 0) { - const errMsg = `MeterValues measurand ${ + const errorMsg = `MeterValues measurand ${ measurandType ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER }: powerDivider have zero or below value ${chargingStation.powerDivider.toString()}` - logger.error(`${chargingStation.logPrefix()} ${errMsg}`) - throw new OCPPError(ErrorType.INTERNAL_ERROR, errMsg, RequestCommand.METER_VALUES) + logger.error(`${chargingStation.logPrefix()} ${errorMsg}`) + throw new OCPPError(ErrorType.INTERNAL_ERROR, errorMsg, RequestCommand.METER_VALUES) } } diff --git a/src/performance/PerformanceStatistics.ts b/src/performance/PerformanceStatistics.ts index 008350da..07439a29 100644 --- a/src/performance/PerformanceStatistics.ts +++ b/src/performance/PerformanceStatistics.ts @@ -71,9 +71,9 @@ export class PerformanceStatistics { public static deleteInstance (objId: string | undefined): boolean { if (objId == null) { - const errMsg = 'Cannot delete performance statistics instance without specifying object id' - logger.error(`${PerformanceStatistics.logPrefix()} ${errMsg}`) - throw new BaseError(errMsg) + const errorMsg = 'Cannot delete performance statistics instance without specifying object id' + logger.error(`${PerformanceStatistics.logPrefix()} ${errorMsg}`) + throw new BaseError(errorMsg) } return PerformanceStatistics.instances.delete(objId) } @@ -98,19 +98,19 @@ export class PerformanceStatistics { uri: undefined | URL ): PerformanceStatistics | undefined { if (objId == null) { - const errMsg = 'Cannot get performance statistics instance without specifying object id' - logger.error(`${PerformanceStatistics.logPrefix()} ${errMsg}`) - throw new BaseError(errMsg) + const errorMsg = 'Cannot get performance statistics instance without specifying object id' + logger.error(`${PerformanceStatistics.logPrefix()} ${errorMsg}`) + throw new BaseError(errorMsg) } if (objName == null) { - const errMsg = 'Cannot get performance statistics instance without specifying object name' - logger.error(`${PerformanceStatistics.logPrefix()} ${errMsg}`) - throw new BaseError(errMsg) + const errorMsg = 'Cannot get performance statistics instance without specifying object name' + logger.error(`${PerformanceStatistics.logPrefix()} ${errorMsg}`) + throw new BaseError(errorMsg) } if (uri == null) { - const errMsg = 'Cannot get performance statistics instance without specifying object uri' - logger.error(`${PerformanceStatistics.logPrefix()} ${errMsg}`) - throw new BaseError(errMsg) + const errorMsg = 'Cannot get performance statistics instance without specifying object uri' + logger.error(`${PerformanceStatistics.logPrefix()} ${errorMsg}`) + throw new BaseError(errorMsg) } if (!PerformanceStatistics.instances.has(objId)) { PerformanceStatistics.instances.set(objId, new PerformanceStatistics(objId, objName, uri))