Refine a bit OCPP services instantiation error message
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 21 Feb 2022 20:31:35 +0000 (21:31 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 21 Feb 2022 20:31:35 +0000 (21:31 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts

index d0d7bf09c697b3221133ac4979bab5c8686f50ea..9377c605cb94a966c201361311f5eae4e0394fc5 100644 (file)
@@ -30,7 +30,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
 
   public constructor(chargingStation: ChargingStation) {
     if (new.target?.name === 'OCPP16IncomingRequestService') {
-      throw new TypeError('Cannot construct OCPP16IncomingRequestService instances directly');
+      throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
     }
     super(chargingStation);
     this.incomingRequestHandlers = new Map<OCPP16IncomingRequestCommand, IncomingRequestHandler>([
index 0385f45a5eee50714ad4db8e93c4a85c8c9020c8..8141b29fef16df8c05eabfe0dfa4771308c4672d 100644 (file)
@@ -28,7 +28,7 @@ import logger from '../../../utils/Logger';
 export default class OCPP16RequestService extends OCPPRequestService {
   public constructor(chargingStation: ChargingStation, ocppResponseService: OCPPResponseService) {
     if (new.target?.name === 'OCPP16RequestService') {
-      throw new TypeError('Cannot construct OCPP16RequestService instances directly');
+      throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
     }
     super(chargingStation, ocppResponseService);
   }
index 876cc80b978915fddfa3805f33e6abcc67a6f391..20255d7d49fdee0e2c95c5b2caed4d043b4e1f61 100644 (file)
@@ -22,7 +22,7 @@ export default class OCPP16ResponseService extends OCPPResponseService {
 
   public constructor(chargingStation: ChargingStation) {
     if (new.target?.name === 'OCPP16ResponseService') {
-      throw new TypeError('Cannot construct OCPP16ResponseService instances directly');
+      throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
     }
     super(chargingStation);
     this.responseHandlers = new Map<OCPP16RequestCommand, ResponseHandler>([