ddsketch/canonical/
error.rs1use std::fmt;
4
5#[derive(Debug, Clone, PartialEq)]
7pub enum ProtoConversionError {
8 MissingMapping,
10
11 GammaMismatch {
13 expected: f64,
15 actual: f64,
17 },
18
19 NonZeroIndexOffset {
21 actual: f64,
23 },
24
25 UnsupportedInterpolation {
27 actual: i32,
29 },
30
31 NegativeBinCount {
33 index: i32,
35 count: f64,
37 },
38
39 NonIntegerBinCount {
41 index: i32,
43 count: f64,
45 },
46
47 NegativeZeroCount {
49 count: f64,
51 },
52
53 NonIntegerZeroCount {
55 count: f64,
57 },
58}
59
60impl fmt::Display for ProtoConversionError {
61 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
62 match self {
63 Self::MissingMapping => write!(f, "protobuf message is missing required mapping field"),
64 Self::GammaMismatch { expected, actual } => {
65 write!(f, "gamma mismatch: expected {}, got {}", expected, actual)
66 }
67 Self::NonZeroIndexOffset { actual } => {
68 write!(f, "non-zero index offset not supported: {}", actual)
69 }
70 Self::UnsupportedInterpolation { actual } => {
71 write!(f, "unsupported interpolation mode: {}", actual)
72 }
73 Self::NegativeBinCount { index, count } => {
74 write!(f, "negative bin count at index {}: {}", index, count)
75 }
76 Self::NonIntegerBinCount { index, count } => {
77 write!(f, "non-integer bin count at index {}: {}", index, count)
78 }
79 Self::NegativeZeroCount { count } => {
80 write!(f, "negative zero count: {}", count)
81 }
82 Self::NonIntegerZeroCount { count } => {
83 write!(f, "non-integer zero count: {}", count)
84 }
85 }
86 }
87}
88
89impl std::error::Error for ProtoConversionError {}