Initial portage to TypeScript.
[e-mobility-charging-stations-simulator.git] / src / charging-station / OcppError.ts
CommitLineData
6af9012e 1import Constants from '../utils/Constants';
38c8fd6c 2
3f40bc9c 3export default class OCPPError extends Error {
6af9012e
JB
4 code;
5 details;
6
7 constructor(code, message, details?) {
7dde0b73
JB
8 super(message);
9
38c8fd6c
JB
10 this.code = code || Constants.OCPP_ERROR_GENERIC_ERROR;
11 this.message = message || '';
12 this.details = details || {};
7dde0b73 13
6af9012e 14 Object.setPrototypeOf(this, OCPPError.prototype); // For instanceof
7dde0b73 15
72766a82 16 Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : (this.stack = (new Error()).stack);
7dde0b73
JB
17 }
18}