import { OCPPServiceUtils } from './OCPPServiceUtils';
import type { ChargingStation } from '../../charging-station';
import { OCPPError } from '../../exception';
-// import { PerformanceStatistics } from '../../performance';
-import { PerformanceStatistics } from '../../performance/PerformanceStatistics';
+import { PerformanceStatistics } from '../../performance';
import {
- type EmptyObject,
type ErrorCallback,
type ErrorResponse,
ErrorType,
- type HandleErrorParams,
type IncomingRequestCommand,
type JsonObject,
type JsonType,
type ResponseCallback,
type ResponseType,
} from '../../types';
-import { Constants, Utils, logger } from '../../utils';
+import { Constants, ErrorUtils, Utils, logger } from '../../utils';
const moduleName = 'OCPPRequestService';
commandName
);
} catch (error) {
- this.handleSendMessageError(chargingStation, commandName, error as Error, {
+ ErrorUtils.handleSendMessageError(chargingStation, commandName, error as Error, {
throwError: true,
});
}
commandName
);
} catch (error) {
- this.handleSendMessageError(chargingStation, commandName, error as Error);
+ ErrorUtils.handleSendMessageError(chargingStation, commandName, error as Error);
}
}
throwError: false,
}
): Promise<ResponseType> {
+ params = {
+ ...{ skipBufferingOnError: false, triggerMessage: false, throwError: false },
+ ...params,
+ };
try {
return await this.internalSendMessage(
chargingStation,
params
);
} catch (error) {
- this.handleSendMessageError(chargingStation, commandName, error as Error, {
+ ErrorUtils.handleSendMessageError(chargingStation, commandName, error as Error, {
throwError: params.throwError,
});
}
params: RequestParams = {
skipBufferingOnError: false,
triggerMessage: false,
+ throwError: false,
}
): Promise<ResponseType> {
+ params = {
+ ...{ skipBufferingOnError: false, triggerMessage: false, throwError: false },
+ ...params,
+ };
if (
(chargingStation.inUnknownState() === true &&
commandName === RequestCommand.BOOT_NOTIFICATION) ||
return messageToSend;
}
- private handleSendMessageError(
- chargingStation: ChargingStation,
- commandName: RequestCommand | IncomingRequestCommand,
- error: Error,
- params: HandleErrorParams<EmptyObject> = { throwError: false }
- ): void {
- logger.error(`${chargingStation.logPrefix()} Request command '${commandName}' error:`, error);
- if (params?.throwError === true) {
- throw error;
- }
- }
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public abstract requestHandler<ReqType extends JsonType, ResType extends JsonType>(
chargingStation: ChargingStation,