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