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