Improve error handling.
[e-mobility-charging-stations-simulator.git] / src / charging-station / OcppError.js
index df9cc425288a18fd504c96b5ee9d20e25f947ca8..2bef07d4f2770b91e047738fe3ed48e45e5f5c07 100644 (file)
@@ -1,10 +1,12 @@
+import Constants from '../utils/Constants.js';
+
 export default class OCPPError extends Error {
   constructor(code, message, details) {
     super(message);
 
-    this.code = code;
-    this.message = message;
-    this.details = details;
+    this.code = code || Constants.OCPP_ERROR_GENERIC_ERROR;
+    this.message = message || '';
+    this.details = details || {};
 
     Object.setPrototypeOf(this, OCPPError.prototype); // for instanceof