1use thiserror::Error;
2
3#[derive(Error, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8pub enum Error {
9 #[error(transparent)]
11 BinaryOperationError(#[from] BinaryOperationError),
12 #[error(transparent)]
14 AxisError(#[from] AxisError),
15}
16
17#[derive(Error, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
18#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
19#[error("histogram binary operation failed (check binning?)")]
22pub struct BinaryOperationError;
23
24#[derive(Error, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
26#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
27pub enum AxisError {
28 #[error("number of bins should be positive and non-zero and must be convertible to the coordinate type")]
30 InvalidNumberOfBins,
31 #[error("Invalid axis range. Low edge should not equal high edge.")]
33 InvalidAxisRange,
34 #[error("axis step size should be non-zero and positive")]
36 InvalidStepSize,
37 #[error("the number of bin edges must be at >= 2.")]
39 InvalidNumberOfBinEdges,
40 #[error("failed to sort bin_edges. The list of axis bin edges must be sortable.")]
42 FailedToSortBinEdges,
43}