Commit | Line | Data |
---|---|---|
edd13439 | 1 | // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved. |
b4d34251 | 2 | |
2896e06d | 3 | import { BaseError } from './internal'; |
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, | |
5cc4b63b | 21 | details?: JsonType |
e7aeea18 | 22 | ) { |
14763b46 JB |
23 | super(message); |
24 | ||
14763b46 | 25 | this.code = code ?? ErrorType.GENERIC_ERROR; |
9292e32a | 26 | this.command = command; |
59b6ed8d | 27 | this.details = details ?? Constants.EMPTY_FREEZED_OBJECT; |
14763b46 JB |
28 | } |
29 | } |