Refine TS and linter configuration
[e-mobility-charging-stations-simulator.git] / src / exception / OCPPError.ts
CommitLineData
b4d34251
JB
1// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
2
6c1761d4 3import type { JsonType } from '../types/JsonType';
8114d10e 4import { ErrorType } from '../types/ocpp/ErrorType';
6c1761d4 5import type { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests';
e58068fd 6import BaseError from './BaseError';
14763b46 7
e7accadb 8export default class OCPPError extends BaseError {
b3ec7bc1 9 code: ErrorType;
a6b3c6c3 10 command?: RequestCommand | IncomingRequestCommand;
5cc4b63b 11 details?: JsonType;
14763b46 12
e7aeea18 13 constructor(
b3ec7bc1 14 code: ErrorType,
e7aeea18
JB
15 message: string,
16 command?: RequestCommand | IncomingRequestCommand,
5cc4b63b 17 details?: JsonType
e7aeea18 18 ) {
14763b46
JB
19 super(message);
20
14763b46 21 this.code = code ?? ErrorType.GENERIC_ERROR;
9292e32a 22 this.command = command;
14763b46 23 this.details = details ?? {};
14763b46
JB
24 }
25}