refactor: use Error static function to generate BaseError stack trace
[e-mobility-charging-stations-simulator.git] / src / exception / BaseError.ts
1 export class BaseError extends Error {
2 public date: Date
3
4 public constructor (message?: string) {
5 super(message)
6 this.name = new.target.name
7 this.date = new Date()
8 Object.setPrototypeOf(this, new.target.prototype)
9 if (typeof Error.captureStackTrace === 'function') {
10 Error.captureStackTrace(this, BaseError)
11 }
12 }
13 }