X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPError.ts;h=cdb75027986bf1413b0571bc5d908f4bed0217b5;hb=85d206672d2dc688827177e4de87a069c4b2cdc1;hp=9c6f825a6526a3f903c4b2a70e230b6fb2de3103;hpb=9292e32a92f3ef63ee5a3cf86dc497b8acae5d2d;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPError.ts b/src/charging-station/ocpp/OCPPError.ts index 9c6f825a..cdb75027 100644 --- a/src/charging-station/ocpp/OCPPError.ts +++ b/src/charging-station/ocpp/OCPPError.ts @@ -1,23 +1,20 @@ +// Partial Copyright Jerome Benoit. 2021. All Rights Reserved. + import { IncomingRequestCommand, RequestCommand } from '../../types/ocpp/Requests'; +import BaseError from '../../exception/BaseError'; import { ErrorType } from '../../types/ocpp/ErrorType'; -export default class OCPPError extends Error { +export default class OCPPError extends BaseError { code: ErrorType | IncomingRequestCommand; command?: RequestCommand | IncomingRequestCommand; - details?: unknown; + details?: Record; - constructor(code: ErrorType | IncomingRequestCommand, message: string, command?: RequestCommand | IncomingRequestCommand, details?: unknown) { + constructor(code: ErrorType | IncomingRequestCommand, message: string, command?: RequestCommand | IncomingRequestCommand, details?: Record) { super(message); - this.name = new.target.name; this.code = code ?? ErrorType.GENERIC_ERROR; - this.message = message ?? ''; this.command = command; this.details = details ?? {}; - - Object.setPrototypeOf(this, new.target.prototype); - - Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : (this.stack = (new Error()).stack); } }