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