27876dadfef495d674f6cae7422fa793129a09b5
[e-mobility-charging-stations-simulator.git] / src / exception / OCPPError.ts
1 // Partial Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
2
3 import { BaseError } from './BaseError.js'
4 import type { ErrorType, IncomingRequestCommand, JsonType, RequestCommand } from '../types/index.js'
5 import { Constants } from '../utils/index.js'
6
7 export class OCPPError extends BaseError {
8 code: ErrorType
9 command: RequestCommand | IncomingRequestCommand
10 details?: JsonType
11
12 constructor (
13 code: ErrorType,
14 message: string,
15 command?: RequestCommand | IncomingRequestCommand,
16 details?: JsonType
17 ) {
18 super(message)
19
20 this.code = code
21 this.command = command ?? Constants.UNKNOWN_OCPP_COMMAND
22 this.details = details
23 }
24 }