Skip to main content

matchmaker_partial/
errors.rs

1use std::fmt;
2use thiserror::Error;
3
4#[derive(Debug, PartialEq, Error)]
5pub enum SimpleError {
6    #[error("expected a single value")]
7    ExpectedSingle,
8
9    #[error("invalid type: expected {expected}, got `{found}`")]
10    InvalidType {
11        expected: &'static str,
12        found: String,
13    },
14
15    #[error("{0}")]
16    Custom(String),
17
18    #[error("Parse failure: {0}")]
19    ParseFailure(String),
20}
21
22impl serde::de::Error for SimpleError {
23    fn custom<T: fmt::Display>(msg: T) -> Self {
24        SimpleError::Custom(msg.to_string())
25    }
26}
27
28#[derive(Debug, PartialEq, thiserror::Error)]
29pub enum PartialSetError {
30    #[error("Unknown field: {0}")]
31    Missing(String),
32    #[error("Expected more paths after: {0}")]
33    EarlyEnd(String),
34    #[error("Unexpected paths after a concrete field: {0:?}")]
35    ExtraPaths(Vec<String>),
36    #[error(transparent)]
37    Deserialization(#[from] SimpleError),
38}