From e76a841c7e2fce7e9f3151d0507ef94454285e79 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 27 Mar 2026 21:50:43 +0100 Subject: [PATCH] =?utf8?q?refactor:=20harmonize=20errMsg=20=E2=86=92=20err?= =?utf8?q?orMsg=20for=20intra-file=20naming=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. --- src/charging-station/ocpp/OCPPServiceUtils.ts | 24 +++++++++---------- src/performance/PerformanceStatistics.ts | 24 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) 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)) -- 2.53.0