egui_charts/model/
parse.rs1use std::fmt;
4
5#[derive(Clone, Debug, PartialEq, Eq)]
7pub struct ParseError {
8 kind: &'static str,
9 input: String,
10 reason: &'static str,
11}
12
13impl ParseError {
14 pub(crate) fn new(kind: &'static str, input: &str, reason: &'static str) -> Self {
15 Self {
16 kind,
17 input: input.to_owned(),
18 reason,
19 }
20 }
21
22 pub fn input(&self) -> &str {
24 &self.input
25 }
26}
27
28impl fmt::Display for ParseError {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 write!(f, "invalid {} {:?}: {}", self.kind, self.input, self.reason)
31 }
32}
33
34impl std::error::Error for ParseError {}