Commit | Line | Data |
---|---|---|
edd13439 | 1 | // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved. |
b4d34251 | 2 | |
bfa591a3 | 3 | import { BaseError } from './BaseError'; |
268a74bb JB |
4 | import { |
5 | ErrorType, | |
6 | type IncomingRequestCommand, | |
7 | type JsonType, | |
8 | type RequestCommand, | |
9 | } from '../types'; | |
59b6ed8d | 10 | import { Constants } from '../utils'; |
14763b46 | 11 | |
268a74bb | 12 | export 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 | } |