rainbow_core/errors/
mod.rs1#[cfg(feature = "html")]
2mod from_html;
3pub type Result<T> = std::result::Result<T, RainbowError>;
4
5#[derive(Debug, Clone, PartialEq)]
6pub struct RainbowError {
7 kind: ErrorKind,
8}
9
10#[derive(Debug, Clone, PartialEq)]
11pub enum ErrorKind {
12 DuplicateDeclaration(String),
13 SyntaxError(String),
14}
15
16impl RainbowError {
17 pub fn duplicate_declaration(name: &str) -> Self {
18 Self { kind: ErrorKind::DuplicateDeclaration(name.to_string()) }
19 }
20 pub fn syntax_error<S>(msg: S) -> Self
21 where
22 S: Into<String>,
23 {
24 Self { kind: ErrorKind::SyntaxError(msg.into()) }
25 }
26}