pilota_thrift_parser/parser/
error.rs1use faststr::FastStr;
2
3#[derive(thiserror::Error)]
4pub enum Error {
5 #[error("IO error: {0}")]
6 IO(std::io::Error),
7 #[error("File not found: {0}")]
8 FileNotFound(std::path::PathBuf),
9 #[error("Syntax error: {source}")]
10 Syntax {
11 summary: FastStr,
12 #[source]
13 source: anyhow::Error,
14 },
15}
16
17impl std::fmt::Debug for Error {
19 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20 match self {
21 Error::Syntax { summary, .. } => {
22 write!(f, "{}", summary)
23 }
24 Error::IO(error) => write!(f, "{}", error),
25 Error::FileNotFound(path_buf) => write!(f, "{}", path_buf.display()),
26 }
27 }
28}