refactor: consolidate default values handling
[e-mobility-charging-stations-simulator.git] / src / exception / OCPPError.ts
CommitLineData
a19b897d 1// Partial Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
b4d34251 2
66a7748d 3import { BaseError } from './BaseError.js'
fba0276c 4import type { ErrorType, IncomingRequestCommand, JsonType, RequestCommand } from '../types/index.js'
66a7748d 5import { Constants } from '../utils/index.js'
14763b46 6
268a74bb 7export class OCPPError extends BaseError {
66a7748d 8 code: ErrorType
fba0276c 9 command: RequestCommand | IncomingRequestCommand
66a7748d 10 details?: JsonType
14763b46 11
66a7748d 12 constructor (
b3ec7bc1 13 code: ErrorType,
e7aeea18
JB
14 message: string,
15 command?: RequestCommand | IncomingRequestCommand,
66a7748d 16 details?: JsonType
e7aeea18 17 ) {
66a7748d 18 super(message)
14763b46 19
66a7748d 20 this.code = code
1feac591 21 this.command = command ?? Constants.UNKNOWN_OCPP_COMMAND
66a7748d 22 this.details = details
14763b46
JB
23 }
24}