1#![deny(missing_docs)]
4
5pub mod action;
7
8pub mod appliers;
10
11pub mod workspace;
13
14pub mod fs_workspace;
16
17pub mod trigger;
19
20pub use debversion::Version;
21pub use trigger::{ChangelogAspect, Trigger, WatchAspect};
22pub use workspace::{Workspace, compat_level};
23
24#[derive(Debug)]
26pub enum Error {
27 NotFound,
29 Io(std::io::Error),
31 Parse(String),
33 Other(String),
35 MissingDependency(String),
37}
38
39impl std::fmt::Display for Error {
40 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
41 match self {
42 Error::NotFound => write!(f, "file not found"),
43 Error::Io(e) => write!(f, "I/O error: {}", e),
44 Error::Parse(msg) => write!(f, "parse error: {}", msg),
45 Error::Other(msg) => write!(f, "{}", msg),
46 Error::MissingDependency(dep) => write!(f, "missing dependency: {}", dep),
47 }
48 }
49}
50
51impl std::error::Error for Error {
52 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
53 match self {
54 Error::Io(e) => Some(e),
55 _ => None,
56 }
57 }
58}
59
60impl From<debian_analyzer::editor::EditorError> for Error {
61 fn from(e: debian_analyzer::editor::EditorError) -> Self {
62 match e {
63 debian_analyzer::editor::EditorError::IoError(e) => Error::Io(e),
64 debian_analyzer::editor::EditorError::BrzError(e) => Error::Other(e.to_string()),
65 debian_analyzer::editor::EditorError::GeneratedFile(p, _) => {
66 Error::Other(format!("generated file: {}", p.display()))
67 }
68 debian_analyzer::editor::EditorError::FormattingUnpreservable(p, _) => {
69 Error::Other(format!("formatting unpreservable: {}", p.display()))
70 }
71 debian_analyzer::editor::EditorError::TemplateError(p, _) => {
72 Error::Other(format!("template error in {}", p.display()))
73 }
74 }
75 }
76}
77
78impl From<std::io::Error> for Error {
79 fn from(e: std::io::Error) -> Self {
80 if e.kind() == std::io::ErrorKind::NotFound {
81 Error::NotFound
82 } else {
83 Error::Io(e)
84 }
85 }
86}