equt_md_error/
lib.rs

1//! This crate includes all errors might occur in [`equt_md`] related crates.
2//!
3//! [`equt_md`]: https://docs.rs/equt-md/*/equt_md/struct.Parser.html
4use katex;
5use serde_yaml;
6use thiserror::Error as E;
7
8/// A specialized [`Result`] type for markdown operations.
9///
10/// This type is broadly used across [`equt_md`] and all its related crates for
11/// any operation which may produce an error.
12///
13/// [`Result`]: https://doc.rust-lang.org/std/result/enum.Result.html
14/// [`equt_md`]: https://docs.rs/equt-md/*/equt_md/struct.Parser.html
15pub type Result<T> = std::result::Result<T, Error>;
16
17/// An enum contains all errors might occur.
18#[derive(Debug, E)]
19pub enum Error {
20    /// Come from an IOError, occurs while rendering output.
21    #[error("io error: {0}")]
22    IOError(#[from] std::io::Error),
23
24    /// Currently only occurs while parsing the frontmatter YAML.
25    #[error("(de)serializing error: {0}")]
26    SerError(#[from] serde_yaml::Error),
27
28    /// Occurs while rendering MathJax expression.
29    #[error("math error: {0}")]
30    KaTeXError(#[from] katex::Error),
31}