build(deps-dev): apply updates
[e-mobility-charging-stations-simulator.git] / src / exception / BaseError.ts
index e1a82c001ac2718b99c12d15975278183157b223..6b9ea70fd914de381f4bf90a82abd9778dc8c9fd 100644 (file)
@@ -1,8 +1,14 @@
-export default class BaseError extends Error {
-  public constructor(message?: string) {
-    super(message);
-    this.name = new.target.name;
-    Object.setPrototypeOf(this, new.target.prototype);
-    Error.captureStackTrace ? (Error.captureStackTrace(this, this.constructor)) : (this.stack = (new Error()).stack);
+export class BaseError extends Error {
+  public constructor (message?: string) {
+    super(message)
+    this.name = new.target.name
+    Object.setPrototypeOf(this, new.target.prototype)
+    typeof Error.captureStackTrace === 'function'
+      ? Error.captureStackTrace(this, this.constructor)
+      : this.createStack()
+  }
+
+  private createStack (): void {
+    this.stack = new Error().stack
   }
 }