matterbridge-roborock-vacuum-plugin
Version:
Matterbridge Roborock Vacuum Plugin
39 lines • 1.18 kB
JavaScript
/**
* Base error class for all plugin errors.
* Provides common error structure with error codes, status codes, and metadata.
*/
export class BaseError extends Error {
code;
statusCode;
metadata;
/**
* Creates a new BaseError instance.
* @param message - Human-readable error message
* @param code - Error code for programmatic handling
* @param statusCode - HTTP-like status code (optional)
* @param metadata - Additional context information
*/
constructor(message, code, statusCode, metadata) {
super(message);
this.code = code;
this.statusCode = statusCode;
this.metadata = metadata;
this.name = this.constructor.name;
Error.captureStackTrace(this, this.constructor);
}
/**
* Serialize error to JSON for logging.
* @returns Object representation of the error
*/
toJSON() {
return {
name: this.name,
message: this.message,
code: this.code,
statusCode: this.statusCode,
metadata: this.metadata,
stack: this.stack,
};
}
}
//# sourceMappingURL=BaseError.js.map