1pub type Result<T> = std::result::Result<T, Error>;
2
3#[derive(Debug, thiserror::Error)]
4#[non_exhaustive]
5pub enum Error {
6 #[error("Schema error: {}", .0)]
7 Schema(String),
8 #[error("Templating error: {}", .0)]
9 Template(String),
10 #[error("Unexpected io error: {}", .0)]
11 Io(#[from] std::io::Error),
12 #[error("Avro error: {}", .0)]
13 Avro(#[from] Box<apache_avro::Error>),
14 #[error("Invalid glob pattern: {}", .0)]
15 GlobPattern(#[from] glob::PatternError),
16}
17
18impl From<tera::Error> for Error {
19 fn from(source: tera::Error) -> Self {
20 Error::Template(source.to_string())
21 }
22}
23
24impl From<apache_avro::Error> for Error {
25 fn from(source: apache_avro::Error) -> Self {
26 Error::Avro(source.into())
27 }
28}
29
30#[cfg(test)]
31mod tests {
32 use super::*;
33
34 #[test]
35 fn display() {
36 assert_eq!(
37 "Schema error: Some message",
38 Error::Schema("Some message".into()).to_string()
39 );
40 }
41}