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