import OCPPError from '../exception/OCPPError';
import PerformanceStatistics from '../performance/PerformanceStatistics';
import type { AutomaticTransactionGeneratorConfiguration } from '../types/AutomaticTransactionGenerator';
-import type ChargingStationConfiguration from '../types/ChargingStationConfiguration';
-import type ChargingStationInfo from '../types/ChargingStationInfo';
+import type { ChargingStationConfiguration } from '../types/ChargingStationConfiguration';
+import type { ChargingStationInfo } from '../types/ChargingStationInfo';
import type { ChargingStationOcppConfiguration } from '../types/ChargingStationOcppConfiguration';
-import ChargingStationTemplate, {
+import {
+ type ChargingStationTemplate,
CurrentType,
PowerUnits,
- WsOptions,
+ type WsOptions,
} from '../types/ChargingStationTemplate';
import { SupervisionUrlDistribution } from '../types/ConfigurationData';
import type { ConnectorStatus } from '../types/ConnectorStatus';
error
);
}
- if (messageType === MessageType.CALL_MESSAGE) {
- // Send error
- await this.ocppRequestService.sendError(
- this,
- messageId,
- error as OCPPError,
- commandName ?? requestCommandName ?? null
- );
- } else if (
- [MessageType.CALL_RESULT_MESSAGE, MessageType.CALL_ERROR_MESSAGE].includes(messageType) ===
- true
- ) {
- if (errorCallback) {
- // Reject the deferred promise in case of error at response handling (rejecting an already fulfilled promise is a no-op)
- errorCallback(error as OCPPError, false);
- } else {
- // Remove the request from the cache in case of error at response handling
- this.requests.delete(messageId);
- }
+ switch (messageType) {
+ case MessageType.CALL_MESSAGE:
+ // Send error
+ await this.ocppRequestService.sendError(
+ this,
+ messageId,
+ error as OCPPError,
+ commandName ?? requestCommandName ?? null
+ );
+ break;
+ case MessageType.CALL_RESULT_MESSAGE:
+ case MessageType.CALL_ERROR_MESSAGE:
+ if (errorCallback) {
+ // Reject the deferred promise in case of error at response handling (rejecting an already fulfilled promise is a no-op)
+ errorCallback(error as OCPPError, false);
+ } else {
+ // Remove the request from the cache in case of error at response handling
+ this.requests.delete(messageId);
+ }
+ break;
}
}
}