#[non_exhaustive]
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("invalid bounds: low ({low}) must be less than or equal to high ({high})")]
InvalidBounds {
low: f64,
high: f64,
},
#[error("invalid log bounds: low must be positive for log scale")]
InvalidLogBounds,
#[error("invalid step: step must be positive")]
InvalidStep,
#[error("categorical choices cannot be empty")]
EmptyChoices,
#[error("parameter conflict for '{name}': {reason}")]
ParameterConflict {
name: String,
reason: String,
},
#[error("no completed trials available")]
NoCompletedTrials,
#[error("invalid gamma: {0} must be in (0.0, 1.0)")]
InvalidGamma(f64),
#[error("invalid bandwidth: {0} must be positive")]
InvalidBandwidth(f64),
#[error("KDE requires at least one sample")]
EmptySamples,
#[error("multivariate KDE samples must have at least one dimension")]
ZeroDimensions,
#[error(
"dimension mismatch: expected {expected} dimensions but sample {sample_index} has {got}"
)]
DimensionMismatch {
expected: usize,
got: usize,
sample_index: usize,
},
#[error("bandwidth dimension mismatch: expected {expected} bandwidths but got {got}")]
BandwidthDimensionMismatch {
expected: usize,
got: usize,
},
#[error("trial was pruned")]
TrialPruned,
#[error("objective dimension mismatch: expected {expected} values, got {got}")]
ObjectiveDimensionMismatch {
expected: usize,
got: usize,
},
#[error("internal error: {0}")]
Internal(&'static str),
#[cfg(feature = "async")]
#[error("async task error: {0}")]
TaskError(String),
#[cfg(feature = "journal")]
#[error("storage error: {0}")]
Storage(String),
}
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Debug)]
pub struct TrialPruned;
impl core::fmt::Display for TrialPruned {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "trial was pruned")
}
}
impl From<TrialPruned> for Error {
fn from(_: TrialPruned) -> Self {
Error::TrialPruned
}
}