1 import { ErrorType
} from
'../../types/ocpp/ErrorType';
2 import { IncomingRequestCommand
} from
'../../types/ocpp/Requests';
4 export default class OCPPError
extends Error {
5 code
: ErrorType
| IncomingRequestCommand
;
8 constructor(code
: ErrorType
| IncomingRequestCommand
, message
: string, details
?: unknown
) {
11 this.name
= new.target
.name
;
12 this.code
= code
?? ErrorType
.GENERIC_ERROR
;
13 this.message
= message
?? '';
14 this.details
= details
?? {};
16 Object.setPrototypeOf(this, new.target
.prototype
);
18 Error.captureStackTrace
? Error.captureStackTrace(this, this.constructor
) : (this.stack
= (new Error()).stack
);