1use std::error::Error;
2use std::fmt::Display;
3use std::fmt::Formatter;
4
5pub mod agent;
6
7#[derive(Debug, Eq, PartialEq)]
8pub enum ParseError {
9 Missing(&'static str),
10 Invalid { field: &'static str, value: String },
11}
12
13impl ParseError {
14 pub fn invalid(field: &'static str, value: impl Into<String>) -> Self {
15 Self::Invalid {
16 field,
17 value: value.into(),
18 }
19 }
20}
21
22impl Display for ParseError {
23 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
24 match self {
25 Self::Missing(field) => write!(f, "missing {field}"),
26 Self::Invalid { field, value } => write!(f, "invalid {field}: {value}"),
27 }
28 }
29}
30
31impl Error for ParseError {}