Use the thiserror crate to define an error enum with the #[derive(thiserror::Error)] attribute and annotate variants with #[error(...)] for messages or #[from] for automatic conversion.
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("No config for '{0}'")]
NoConfig(String),
#[error(transparent)]
Mdbook(#[from] mdbook_preprocessor::errors::Error),
}
Add thiserror = "1.0.60" to your Cargo.toml dependencies.