Use a map to store OCPP command statistics
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / OCPPError.ts
1 // Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
2
3 import { IncomingRequestCommand, RequestCommand } from '../../types/ocpp/Requests';
4
5 import BaseError from '../../exception/BaseError';
6 import { ErrorType } from '../../types/ocpp/ErrorType';
7
8 export default class OCPPError extends BaseError {
9 code: ErrorType | IncomingRequestCommand;
10 command?: RequestCommand | IncomingRequestCommand;
11 details?: Record<string, unknown>;
12
13 constructor(code: ErrorType | IncomingRequestCommand, message: string, command?: RequestCommand | IncomingRequestCommand, details?: Record<string, unknown>) {
14 super(message);
15
16 this.code = code ?? ErrorType.GENERIC_ERROR;
17 this.command = command;
18 this.details = details ?? {};
19 }
20 }