build: switch to NodeNext module resolution
[e-mobility-charging-stations-simulator.git] / src / exception / OCPPError.ts
CommitLineData
edd13439 1// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
b4d34251 2
a6ef1ece 3import { BaseError } from './BaseError.js';
268a74bb
JB
4import {
5 ErrorType,
6 type IncomingRequestCommand,
7 type JsonType,
8 type RequestCommand,
a6ef1ece
JB
9} from '../types/index.js';
10import { Constants } from '../utils/index.js';
14763b46 11
268a74bb 12export class OCPPError extends BaseError {
b3ec7bc1 13 code: ErrorType;
a6b3c6c3 14 command?: RequestCommand | IncomingRequestCommand;
5cc4b63b 15 details?: JsonType;
14763b46 16
e7aeea18 17 constructor(
b3ec7bc1 18 code: ErrorType,
e7aeea18
JB
19 message: string,
20 command?: RequestCommand | IncomingRequestCommand,
5edd8ba0 21 details?: JsonType,
e7aeea18 22 ) {
14763b46
JB
23 super(message);
24
7375968c
JB
25 this.code = code;
26 this.command =
27 command ?? (Constants.UNKNOWN_COMMAND as RequestCommand | IncomingRequestCommand);
28 this.details = details;
14763b46
JB
29 }
30}