Consistent naming for CS template enums
[e-mobility-charging-stations-simulator.git] / src / charging-station / OcppError.ts
CommitLineData
d2a64eb5 1import { ErrorType } from '../types/ocpp/ErrorType';
38c8fd6c 2
3f40bc9c 3export default class OCPPError extends Error {
a4a21709 4 code: string;
5b0e583f 5 details?: any;
6af9012e 6
662b4270 7 constructor(code: string, message: string, details?: any) {
7dde0b73
JB
8 super(message);
9
510f0fa5
JB
10 this.code = code ?? ErrorType.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}