Commit | Line | Data |
---|---|---|
a19b897d | 1 | // Partial Copyright Jerome Benoit. 2021-2024. All Rights Reserved. |
b4d34251 | 2 | |
66a7748d | 3 | import { BaseError } from './BaseError.js' |
268a74bb | 4 | import { |
66a7748d | 5 | type ErrorType, |
268a74bb JB |
6 | type IncomingRequestCommand, |
7 | type JsonType, | |
66a7748d JB |
8 | type RequestCommand |
9 | } from '../types/index.js' | |
10 | import { Constants } from '../utils/index.js' | |
14763b46 | 11 | |
268a74bb | 12 | export 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 JB |
25 | this.code = code |
26 | this.command = command ?? (Constants.UNKNOWN_COMMAND as RequestCommand | IncomingRequestCommand) | |
27 | this.details = details | |
14763b46 JB |
28 | } |
29 | } |