X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPError.ts;h=cdb75027986bf1413b0571bc5d908f4bed0217b5;hb=9c613674007bc7bbfb2423269401a188f7c9ce0b;hp=b977062a0957d568180ba9225bfb4fa3f49fcc02;hpb=14763b466177d8e74d2e1925647e04e2d62ac72a;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPError.ts b/src/charging-station/ocpp/OCPPError.ts index b977062a..cdb75027 100644 --- a/src/charging-station/ocpp/OCPPError.ts +++ b/src/charging-station/ocpp/OCPPError.ts @@ -1,20 +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'; -import { IncomingRequestCommand } from '../../types/ocpp/Requests'; -export default class OCPPError extends Error { +export default class OCPPError extends BaseError { code: ErrorType | IncomingRequestCommand; - details?: unknown; + command?: RequestCommand | IncomingRequestCommand; + details?: Record; - constructor(code: ErrorType | IncomingRequestCommand, message: string, 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); } }