1 import { IncomingRequestCommand
, RequestCommand
} from
'../../types/ocpp/Requests';
3 import { ErrorType
} from
'../../types/ocpp/ErrorType';
5 export default class OCPPError
extends Error {
6 code
: ErrorType
| IncomingRequestCommand
;
7 command
?: RequestCommand
| IncomingRequestCommand
;
8 details
?: Record
<string, unknown
>;
10 constructor(code
: ErrorType
| IncomingRequestCommand
, message
: string, command
?: RequestCommand
| IncomingRequestCommand
, details
?: Record
<string, unknown
>) {
13 this.name
= new.target
.name
;
14 this.code
= code
?? ErrorType
.GENERIC_ERROR
;
15 this.message
= message
?? '';
16 this.command
= command
;
17 this.details
= details
?? {};
19 Object.setPrototypeOf(this, new.target
.prototype
);
21 Error.captureStackTrace
? Error.captureStackTrace(this, this.constructor
) : (this.stack
= (new Error()).stack
);