refactor(simulator): switch to named exports
[e-mobility-charging-stations-simulator.git] / src / exception / OCPPError.ts
1 // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
2
3 import { BaseError } from './BaseError';
4 import {
5 ErrorType,
6 type IncomingRequestCommand,
7 type JsonType,
8 type RequestCommand,
9 } from '../types';
10
11 export class OCPPError extends BaseError {
12 code: ErrorType;
13 command?: RequestCommand | IncomingRequestCommand;
14 details?: JsonType;
15
16 constructor(
17 code: ErrorType,
18 message: string,
19 command?: RequestCommand | IncomingRequestCommand,
20 details?: JsonType
21 ) {
22 super(message);
23
24 this.code = code ?? ErrorType.GENERIC_ERROR;
25 this.command = command;
26 this.details = details ?? {};
27 }
28 }