]>
Commit | Line | Data |
---|---|---|
1 | import { ErrorType } from '../types/ocpp/ErrorType'; | |
2 | ||
3 | export default class OCPPError extends Error { | |
4 | code: string; | |
5 | details?: any; | |
6 | ||
7 | constructor(code: string, message: string, details?: any) { | |
8 | super(message); | |
9 | ||
10 | this.code = code ?? ErrorType.GENERIC_ERROR; | |
11 | this.message = message ?? ''; | |
12 | this.details = details ?? {}; | |
13 | ||
14 | Object.setPrototypeOf(this, OCPPError.prototype); // For instanceof | |
15 | ||
16 | Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : (this.stack = (new Error()).stack); | |
17 | } | |
18 | } |