Skip to main content

mdbook_rss_feed/
error.rs

1//! Crate-wide error type.
2
3use std::path::PathBuf;
4use thiserror::Error;
5
6/// Errors produced while collecting articles or building feeds.
7#[derive(Debug, Error)]
8pub enum FeedError {
9    /// Failed to read a file from disk.
10    #[error("failed to read {path}: {source}")]
11    Io {
12        path: PathBuf,
13        #[source]
14        source: std::io::Error,
15    },
16
17    /// A markdown chapter had no usable file stem (e.g. it was a directory).
18    #[error("path has no file stem: {0}")]
19    MissingFileStem(PathBuf),
20
21    /// Walking the `src` directory failed.
22    #[error("failed to walk directory {path}: {source}")]
23    WalkDir {
24        path: PathBuf,
25        #[source]
26        source: walkdir::Error,
27    },
28}
29
30pub type Result<T> = std::result::Result<T, FeedError>;