langfuse_client_base/models/
parse_enum_error.rs1#[derive(Clone, Debug, Eq, PartialEq)]
3pub struct ParseEnumError {
4 type_name: &'static str,
5 value: String,
6}
7
8impl ParseEnumError {
9 pub(crate) fn new(type_name: &'static str, value: &str) -> Self {
10 Self {
11 type_name,
12 value: value.to_owned(),
13 }
14 }
15
16 pub fn type_name(&self) -> &'static str {
18 self.type_name
19 }
20
21 pub fn value(&self) -> &str {
23 &self.value
24 }
25}
26
27impl std::fmt::Display for ParseEnumError {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 write!(
30 f,
31 "invalid value {:?} for enum {}",
32 self.value, self.type_name
33 )
34 }
35}
36
37impl std::error::Error for ParseEnumError {}