1#![doc(html_root_url = "https://docs.rs/syntect/5.3.0")]
23
24#[cfg(test)]
25#[macro_use]
26extern crate pretty_assertions;
27
28#[cfg(any(feature = "dump-load", feature = "dump-create"))]
29pub mod dumps;
30#[cfg(feature = "parsing")]
31pub mod easy;
32#[cfg(feature = "html")]
33mod escape;
34pub mod highlighting;
35#[cfg(feature = "html")]
36pub mod html;
37pub mod parsing;
38pub mod util;
39mod utils;
40
41use std::io::Error as IoError;
42
43#[cfg(feature = "plist-load")]
44use crate::highlighting::{ParseThemeError, SettingsError};
45
46#[derive(Debug, thiserror::Error)]
48#[non_exhaustive]
49pub enum Error {
50 #[error("Loading error: {0}")]
52 LoadingError(#[from] LoadingError),
53 #[cfg(feature = "parsing")]
55 #[error("Parsing error: {0}")]
56 ParsingError(#[from] crate::parsing::ParsingError),
57 #[error("Scope error: {0}")]
59 ScopeError(#[from] crate::parsing::ScopeError),
60 #[error("Formatting error: {0}")]
62 Fmt(#[from] std::fmt::Error),
63 #[error("IO Error: {0}")]
65 Io(#[from] IoError),
66}
67
68#[derive(Debug, thiserror::Error)]
70#[non_exhaustive]
71pub enum LoadingError {
72 #[error("error finding all the files in a directory: {0}")]
74 WalkDir(#[source] Box<dyn std::error::Error + Send + Sync>),
75 #[error("error reading a file: {0}")]
77 Io(#[from] IoError),
78 #[cfg(all(feature = "yaml-load", feature = "parsing"))]
80 #[error("{1}: {0}")]
81 ParseSyntax(#[source] crate::parsing::ParseSyntaxError, String),
82 #[cfg(feature = "metadata")]
84 #[error("Failed to parse JSON")]
85 ParseMetadata(#[source] Box<dyn std::error::Error + Send + Sync>),
86 #[cfg(feature = "plist-load")]
88 #[error("Invalid syntax theme")]
89 ParseTheme(#[from] ParseThemeError),
90 #[cfg(feature = "plist-load")]
92 #[error("Invalid syntax theme settings")]
93 ReadSettings(#[from] SettingsError),
94 #[error("Invalid path")]
97 BadPath,
98}