1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use inquire::InquireError;
use serde_json::Value;
use thiserror::Error;

pub type SchemaResult<T> = core::result::Result<T, SchemaError>;

#[derive(Error, Debug)]
pub enum SchemaError {
    #[error("{0}")]
    Generic(String),

    #[error("{0}")]
    Inquire(#[from] InquireError),

    #[error(
        "interactive-parse generated this json object: {}\n{}",
        serde_json::to_string_pretty(&value).unwrap(),
        serde_error
    )]
    Serde {
        value: Value,
        serde_error: serde_json::Error,
    },

    #[error(
        "Schemas of this type cannot yet be parsed interactively
        Please open an issue at \"https://github.com/ewoolsey/interactive-parse\""
    )]
    SchemaIsBool,

    #[error(
        "Parsing schemas of this type are not yet supported.
        Please open an issue at \"https://github.com/ewoolsey/interactive-parse\""
    )]
    Unimplemented,
}