Skip to main content

mdsite/
lib.rs

1pub mod file_scan;
2pub mod github;
3pub mod markdown;
4pub mod md_parser;
5pub mod render;
6
7use thiserror::Error as ThisError;
8
9pub(crate) type Result<T> = std::result::Result<T, Error>;
10
11// Map of values that can be passed to Renderer
12pub type TomlMap = toml::value::Map<String, toml::value::Value>;
13
14/// Errors generated by this library
15#[derive(ThisError, Debug)]
16pub enum Error {
17    #[error("Parse error reading frontmatter {0}")]
18    FrontmatterParse(String),
19
20    #[error("Error reading handlebars template: {0}")]
21    HandlebarsTemplate(#[from] handlebars::TemplateError),
22
23    #[error("Error processing handlebars template: {0}")]
24    HandlebarsRender(#[from] handlebars::RenderError),
25
26    #[error("Invalid scan dir :{0}")]
27    InvalidScanDir(String),
28
29    #[error("Scan sources parameter cannot be empty")]
30    ScanNoSources,
31
32    #[error("Programmer error")]
33    Bug(String),
34
35    #[error("Policy '{0}', (id:{1}) is missing a 'slug' field. Update the field in Zenkit and try again")]
36    MissingSlug(String, u64),
37
38    #[error("Toml serialization {0}")]
39    TomlSer(#[from] toml::ser::Error),
40
41    #[error("Toml deserialization {0}")]
42    TomlDeSer(#[from] toml::de::Error),
43
44    #[error("IO Error")]
45    Io(#[from] std::io::Error),
46
47    #[error("Github api error for url {0}: {1}")]
48    Github(String, String),
49
50    #[error("Decoding Github content (url {0} with base64 :{1}")]
51    Base64(String, String),
52
53    #[error("Filenames may not contain non-uncode characters. '{0}' is invalid")]
54    NonUnicodeFilename(String),
55
56    #[error("File scan error {0}: To avoid this error, add this file to a .ignore file")]
57    FileScan(String),
58
59    #[error("File parse error {0}: To avoid this error, add this file to a .ignore file")]
60    FileParse(String),
61}