use super::*;
use crate::{filter::FilterError, *};
use snafu::prelude::*;
#[cfg_attr(
feature = "python-bindings",
gen_stub_pyclass_complex_enum,
pyclass(from_py_object)
)]
#[allow(missing_docs)]
#[derive(Debug, Snafu, Clone, PartialEq)]
#[snafu(visibility(pub(crate)))]
pub enum SiggenError {
#[snafu(display(
"The current signal generator settings are incompatible with the stream sampling frequency. Sample rate too low: {}",
fs
))]
SampleRateTooLow { fs: Flt },
#[snafu(display("invalid parameter: {}. {}.", param, criterion))]
InvalidParameter { param: String, criterion: String },
#[snafu(display("parameter {} is out of range: {}", parameter, source))]
ParameterOutOfRange {
source: ValidationError,
parameter: String,
},
#[snafu(display("channel {} is out of range. Highest channel is: {}", channel, nchannels-1))]
ChannelOutOfRange { channel: usize, nchannels: usize },
#[snafu(display("equalizer could not be created due to error: {}", source))]
EqualizerError {
#[snafu(source)]
source: FilterError,
},
}
cfg_select! {
feature = "python-bindings" => {
use pyo3::exceptions::PyException;
use std::fmt::{Display, Formatter};
#[gen_stub_pyclass]
#[pyclass(extends = PyException, str, from_py_object)] #[derive(Debug, Clone)]
pub struct PySiggenError {
#[pyo3(get)]
pub inner: SiggenError,
}
impl Display for PySiggenError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.inner)
}
}
#[gen_stub_pymethods]
#[pymethods]
impl PySiggenError {
#[new]
fn new(inner: SiggenError) -> Self {
PySiggenError { inner }
}
}
impl From<SiggenError> for PyErr {
fn from(value: SiggenError) -> Self {
PyErr::new::<PySiggenError, _>(value)
}
}
},
_ => {}
}