interactive_parse/
error.rs

1use inquire::InquireError;
2use serde_json::Value;
3use thiserror::Error;
4
5pub type SchemaResult<T> = core::result::Result<T, SchemaError>;
6
7#[derive(Error, Debug)]
8pub enum SchemaError {
9    #[error(transparent)]
10    Inquire(#[from] InquireError),
11
12    #[error("{0}")]
13    Generic(String),
14
15    #[error("Undo depth: {depth}")]
16    Undo { depth: u16 },
17
18    #[error("User has exited the prompt")]
19    Exit,
20
21    #[error(
22        "interactive-parse generated this json object: {}\n{}",
23        serde_json::to_string_pretty(&value).unwrap(),
24        serde_error
25    )]
26    Serde {
27        value: Value,
28        serde_error: serde_json::Error,
29    },
30
31    #[error(
32        "Schemas of this type cannot yet be parsed interactively
33        Please open an issue at \"https://github.com/ewoolsey/interactive-parse\""
34    )]
35    SchemaIsBool,
36
37    #[error(
38        "Parsing schemas of this type are not yet supported.
39        Please open an issue at \"https://github.com/ewoolsey/interactive-parse\""
40    )]
41    Unimplemented,
42}