speechmarkdown_rust/
error.rs1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, ParseError>;
5
6#[derive(Error, Debug, Clone, PartialEq)]
8pub enum ParseError {
9 #[error("Grammar error: {0}")]
11 GrammarError(String),
12
13 #[error("Invalid modifier: {0}")]
15 InvalidModifier(String),
16
17 #[error("Invalid value for modifier '{modifier}': {value}")]
19 InvalidModifierValue { modifier: String, value: String },
20
21 #[error("Unsupported platform: {0}")]
23 UnsupportedPlatform(String),
24
25 #[error("Invalid voice '{voice}' for platform '{platform}'")]
27 InvalidVoice { voice: String, platform: String },
28
29 #[error("Invalid language code: {0}")]
31 InvalidLanguage(String),
32
33 #[error("Invalid intensity: {0}")]
35 InvalidIntensity(String),
36
37 #[error("IO error: {0}")]
39 IoError(String),
40
41 #[error("JSON error: {0}")]
43 JsonError(String),
44}
45
46impl From<std::io::Error> for ParseError {
47 fn from(err: std::io::Error) -> Self {
48 ParseError::IoError(err.to_string())
49 }
50}
51
52impl From<serde_json::Error> for ParseError {
53 fn from(err: serde_json::Error) -> Self {
54 ParseError::JsonError(err.to_string())
55 }
56}