Commit | Line | Data |
---|---|---|
edd13439 | 1 | // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved. |
b4d34251 | 2 | |
78202038 | 3 | import BaseError from './BaseError'; |
6c1761d4 | 4 | import type { JsonType } from '../types/JsonType'; |
8114d10e | 5 | import { ErrorType } from '../types/ocpp/ErrorType'; |
6c1761d4 | 6 | import type { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests'; |
14763b46 | 7 | |
e7accadb | 8 | export default class OCPPError extends BaseError { |
b3ec7bc1 | 9 | code: ErrorType; |
a6b3c6c3 | 10 | command?: RequestCommand | IncomingRequestCommand; |
5cc4b63b | 11 | details?: JsonType; |
14763b46 | 12 | |
e7aeea18 | 13 | constructor( |
b3ec7bc1 | 14 | code: ErrorType, |
e7aeea18 JB |
15 | message: string, |
16 | command?: RequestCommand | IncomingRequestCommand, | |
5cc4b63b | 17 | details?: JsonType |
e7aeea18 | 18 | ) { |
14763b46 JB |
19 | super(message); |
20 | ||
14763b46 | 21 | this.code = code ?? ErrorType.GENERIC_ERROR; |
9292e32a | 22 | this.command = command; |
14763b46 | 23 | this.details = details ?? {}; |
14763b46 JB |
24 | } |
25 | } |