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