matterbridge-roborock-vacuum-plugin
Version:
Matterbridge Roborock Vacuum Plugin
60 lines • 1.69 kB
JavaScript
import { BaseError } from './BaseError.js';
/**
* Base class for validation errors.
*/
export class ValidationError extends BaseError {
constructor(message, metadata) {
super(message, 'VALIDATION_ERROR', 400, metadata);
}
}
/**
* Thrown when input parameter is invalid.
*/
export class InvalidParameterError extends ValidationError {
constructor(parameterName, value, reason) {
super(`Invalid parameter: ${parameterName}. ${reason ?? ''}`, {
reason: 'INVALID_PARAMETER',
parameterName,
value,
validationReason: reason,
});
}
}
/**
* Thrown when numeric value is out of valid range.
*/
export class OutOfRangeError extends ValidationError {
constructor(parameterName, value, min, max) {
super(`Parameter ${parameterName} is out of range. Expected: ${min}-${max}, got: ${value}`, {
reason: 'OUT_OF_RANGE',
parameterName,
value,
min,
max,
});
}
}
/**
* Thrown when required parameter is missing.
*/
export class MissingParameterError extends ValidationError {
constructor(parameterName) {
super(`Required parameter is missing: ${parameterName}`, {
reason: 'MISSING_PARAMETER',
parameterName,
});
}
}
/**
* Thrown when data format is invalid.
*/
export class InvalidFormatError extends ValidationError {
constructor(data, expectedFormat) {
super(`Invalid data format. Expected: ${expectedFormat}`, {
reason: 'INVALID_FORMAT',
data,
expectedFormat,
});
}
}
//# sourceMappingURL=ValidationError.js.map