X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPError.ts;h=cdb75027986bf1413b0571bc5d908f4bed0217b5;hb=48132636528412b0d48b22baf35414ab2e917bd1;hp=ed77d54c22fa3446677a96d2328ced2629d26c8f;hpb=a6b3c6c313f1c0314a1445ed630cac85edf55b2c;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPError.ts b/src/charging-station/ocpp/OCPPError.ts index ed77d54c..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.message = command ?? ''; + this.command = command; this.details = details ?? {}; - - Object.setPrototypeOf(this, new.target.prototype); - - Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : (this.stack = (new Error()).stack); } }