Use eslint extension for import sorting instead of unmaintained external ones
[e-mobility-charging-stations-simulator.git] / src / exception / OCPPError.ts
1 // Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
2
3 import { JsonType } from '../types/JsonType';
4 import { ErrorType } from '../types/ocpp/ErrorType';
5 import { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests';
6 import BaseError from './BaseError';
7
8 export default class OCPPError extends BaseError {
9 code: ErrorType;
10 command?: RequestCommand | IncomingRequestCommand;
11 details?: JsonType;
12
13 constructor(
14 code: ErrorType,
15 message: string,
16 command?: RequestCommand | IncomingRequestCommand,
17 details?: JsonType
18 ) {
19 super(message);
20
21 this.code = code ?? ErrorType.GENERIC_ERROR;
22 this.command = command;
23 this.details = details ?? {};
24 }
25 }