]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
refactor: extract ensureError and getErrorMessage helpers
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 16 Mar 2026 15:33:41 +0000 (16:33 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 16 Mar 2026 15:33:41 +0000 (16:33 +0100)
commit207b589dd5273a7cea3127fcf19489ad9d51e286
treed0830b13096c3a66b80472990355d6bde2968058
parent9198720849db66481a48945b930ca4ed53ea99f5
refactor: extract ensureError and getErrorMessage helpers

Replace 61 duplicated error coercion patterns across 18 files:
- 34× 'error instanceof Error ? error : new Error(String(error))'
  → ensureError(error)
- 27× 'error instanceof Error ? error.message : String(error)'
  → getErrorMessage(error)

New helpers in src/utils/ErrorUtils.ts, exported via barrel.
20 files changed:
src/charging-station/ChargingStation.ts
src/charging-station/ChargingStationWorker.ts
src/charging-station/IdTagsCache.ts
src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/2.0/OCPP20CertificateManager.ts
src/charging-station/ocpp/OCPPRequestService.ts
src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts
src/charging-station/ocpp/auth/strategies/LocalAuthStrategy.ts
src/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.ts
src/charging-station/ui-server/UIHttpServer.ts
src/charging-station/ui-server/UIServerUtils.ts
src/charging-station/ui-server/ui-services/AbstractUIService.ts
src/performance/storage/JsonFileStorage.ts
src/performance/storage/MikroOrmStorage.ts
src/performance/storage/MongoDBStorage.ts
src/utils/Configuration.ts
src/utils/ErrorUtils.ts
src/utils/FileUtils.ts
src/utils/index.ts