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