"robohydra",
"sonarlint",
"tsdoc",
+ "VCAP",
"webui"
],
"sonarlint.connectedMode.project": {
type StationTemplateUrl,
type Statistics,
} from '../types';
-import { Configuration, Utils, logger } from '../utils';
+import { Configuration, ErrorUtils, Utils, logger } from '../utils';
import { type MessageHandler, type WorkerAbstract, WorkerFactory } from '../worker';
const moduleName = 'Bootstrap';
private constructor() {
// Enable unconditionally for now
- this.logUnhandledRejection();
- this.logUncaughtException();
+ ErrorUtils.handleUnhandledRejection();
+ ErrorUtils.handleUncaughtException();
this.initializedCounters = false;
this.started = false;
this.initializeCounters();
}
}
- private logUncaughtException(): void {
- process.on('uncaughtException', (error: Error) => {
- console.error(chalk.red('Uncaught exception: '), error);
- });
- }
-
- private logUnhandledRejection(): void {
- process.on('unhandledRejection', (reason: unknown) => {
- console.error(chalk.red('Unhandled rejection: '), reason);
- });
- }
-
private async startChargingStation(
index: number,
stationTemplateUrl: StationTemplateUrl
import WebSocket, { type RawData } from 'ws';
import { AutomaticTransactionGenerator } from './AutomaticTransactionGenerator';
+import { ChargingStationWorkerBroadcastChannel } from './broadcast-channel/ChargingStationWorkerBroadcastChannel';
import { ChargingStationConfigurationUtils } from './ChargingStationConfigurationUtils';
import { ChargingStationUtils } from './ChargingStationUtils';
-import { ChargingStationWorkerBroadcastChannel } from './ChargingStationWorkerBroadcastChannel';
import { IdTagsCache } from './IdTagsCache';
-import { MessageChannelUtils } from './MessageChannelUtils';
import {
OCPP16IncomingRequestService,
OCPP16RequestService,
DCElectricUtils,
ErrorUtils,
FileUtils,
+ MessageChannelUtils,
Utils,
logger,
} from '../utils';
-import type { ChargingStation } from './ChargingStation';
-import { ChargingStationConfigurationUtils } from './ChargingStationConfigurationUtils';
-import { OCPP16ServiceUtils } from './ocpp';
import { WorkerBroadcastChannel } from './WorkerBroadcastChannel';
-import { BaseError, type OCPPError } from '../exception';
+import { BaseError, type OCPPError } from '../../exception';
import {
AuthorizationStatus,
type AuthorizeRequest,
type StatusNotificationResponse,
type StopTransactionRequest,
type StopTransactionResponse,
-} from '../types';
-import { Constants, Utils, logger } from '../utils';
+} from '../../types';
+import { Constants, Utils, logger } from '../../utils';
+import type { ChargingStation } from '../ChargingStation';
+import { ChargingStationConfigurationUtils } from '../ChargingStationConfigurationUtils';
+import { OCPP16ServiceUtils } from '../ocpp';
const moduleName = 'ChargingStationWorkerBroadcastChannel';
-import type { AbstractUIService } from './ui-server/ui-services/AbstractUIService';
import { WorkerBroadcastChannel } from './WorkerBroadcastChannel';
import {
type BroadcastChannelResponse,
type MessageEvent,
type ResponsePayload,
ResponseStatus,
-} from '../types';
-import { Utils, logger } from '../utils';
+} from '../../types';
+import { Utils, logger } from '../../utils';
+import type { AbstractUIService } from '../ui-server/ui-services/AbstractUIService';
const moduleName = 'UIServiceWorkerBroadcastChannel';
BroadcastChannelResponse,
JsonType,
MessageEvent,
-} from '../types';
-import { Utils, logger } from '../utils';
+} from '../../types';
+import { Utils, logger } from '../../utils';
const moduleName = 'WorkerBroadcastChannel';
export type { ChargingStation } from './ChargingStation';
export { ChargingStationConfigurationUtils } from './ChargingStationConfigurationUtils';
export { ChargingStationUtils } from './ChargingStationUtils';
-export { MessageChannelUtils } from './MessageChannelUtils';
type ChargingStation,
ChargingStationConfigurationUtils,
ChargingStationUtils,
- MessageChannelUtils,
} from '../../../charging-station';
import { OCPPError } from '../../../exception';
import {
type SetChargingProfileResponse,
type UnlockConnectorResponse,
} from '../../../types';
-import { Constants, Utils, logger } from '../../../utils';
+import { Constants, MessageChannelUtils, Utils, logger } from '../../../utils';
import { OCPPResponseService } from '../OCPPResponseService';
const moduleName = 'OCPP16ResponseService';
import { OCPPError } from '../../exception';
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);
}
}
params
);
} catch (error) {
- this.handleSendMessageError(chargingStation, commandName, error as Error, {
+ ErrorUtils.handleSendMessageError(chargingStation, commandName, error as Error, {
throwError: params.throwError,
});
}
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,
} from '../../../types';
import { Utils, logger } from '../../../utils';
import { Bootstrap } from '../../Bootstrap';
-import { UIServiceWorkerBroadcastChannel } from '../../UIServiceWorkerBroadcastChannel';
+import { UIServiceWorkerBroadcastChannel } from '../../broadcast-channel/UIServiceWorkerBroadcastChannel';
import type { AbstractUIServer } from '../AbstractUIServer';
const moduleName = 'AbstractUIService';
import type { URL } from 'node:url';
import { parentPort } from 'node:worker_threads';
-import { MessageChannelUtils } from '../charging-station';
import {
type IncomingRequestCommand,
MessageType,
type Statistics,
type TimeSeries,
} from '../types';
-import { CircularArray, Configuration, Constants, Utils, logger } from '../utils';
+import {
+ CircularArray,
+ Configuration,
+ Constants,
+ MessageChannelUtils,
+ Utils,
+ logger,
+} from '../utils';
export class PerformanceStatistics {
private static readonly instances: Map<string, PerformanceStatistics> = new Map<
import { logger } from './Logger';
import { Utils } from './Utils';
-import type { EmptyObject, FileType, HandleErrorParams } from '../types';
+import type { ChargingStation } from '../charging-station';
+import type {
+ EmptyObject,
+ FileType,
+ HandleErrorParams,
+ IncomingRequestCommand,
+ RequestCommand,
+} from '../types';
export class ErrorUtils {
private constructor() {
// This is intentional
}
+ public static handleUncaughtException(): void {
+ process.on('uncaughtException', (error: Error) => {
+ console.error(chalk.red('Uncaught exception: '), error);
+ });
+ }
+
+ public static handleUnhandledRejection(): void {
+ process.on('unhandledRejection', (reason: unknown) => {
+ console.error(chalk.red('Unhandled rejection: '), reason);
+ });
+ }
+
public static handleFileException(
file: string,
fileType: FileType,
throw error;
}
}
+
+ public static 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;
+ }
+ }
}
-import type { ChargingStation } from './ChargingStation';
+import type { ChargingStation } from '../charging-station';
import {
type ChargingStationData,
type ChargingStationWorkerMessage,
export { Constants } from './Constants';
export { ErrorUtils } from './ErrorUtils';
export { FileUtils } from './FileUtils';
+export { MessageChannelUtils } from './MessageChannelUtils';
export { Utils } from './Utils';
export { logger } from './Logger';