Skip to main content

telegram_markdown_v2/
errors.rs

1use markdown::message::Message;
2use thiserror::Error;
3
4/// Convenience result type used across this crate.
5pub type Result<T> = std::result::Result<T, Error>;
6
7/// Errors returned while converting Markdown into Telegram MarkdownV2.
8#[non_exhaustive]
9#[derive(Debug, Error)]
10pub enum Error {
11    /// A regular expression used internally could not be compiled.
12    #[error("failed to compile regex '{name}'")]
13    RegexCompile {
14        /// Stable identifier for the regex used in diagnostics and tests.
15        name: &'static str,
16        /// Regex pattern string that failed compilation.
17        pattern: &'static str,
18        #[source]
19        /// Underlying regex engine error.
20        source: regex::Error,
21    },
22
23    /// Markdown parser failed to parse the input document.
24    #[error("failed to parse markdown input: {message}")]
25    MarkdownParse { message: Message },
26}