refactor: type casting cleanups
[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'
268a74bb 4import {
66a7748d 5 type ErrorType,
268a74bb
JB
6 type IncomingRequestCommand,
7 type JsonType,
66a7748d
JB
8 type RequestCommand
9} from '../types/index.js'
10import { Constants } from '../utils/index.js'
14763b46 11
268a74bb 12export class OCPPError extends BaseError {
66a7748d
JB
13 code: ErrorType
14 command?: RequestCommand | IncomingRequestCommand
15 details?: JsonType
14763b46 16
66a7748d 17 constructor (
b3ec7bc1 18 code: ErrorType,
e7aeea18
JB
19 message: string,
20 command?: RequestCommand | IncomingRequestCommand,
66a7748d 21 details?: JsonType
e7aeea18 22 ) {
66a7748d 23 super(message)
14763b46 24
66a7748d 25 this.code = code
3ccfabff 26 this.command = command ?? Constants.UNKNOWN_COMMAND
66a7748d 27 this.details = details
14763b46
JB
28 }
29}