Skip to main content

grp_core/error/errors/
parsing.rs

1use std::fmt::Display;
2use color_print::cformat;
3
4use crate::{error::structs::Error, make_error};
5
6
7pub struct Parsing;
8macro_rules! etype {
9    ($literal:literal) => { concat!("parsing::", $literal) };
10}
11
12impl Parsing {
13    pub fn serde<P: Display>(error: P, text: &str) -> Error {
14        make_error!{
15            etype!("serde"), "Error parsing a serde object",
16            2 of 
17                cformat!("<y>* {}</>", error),
18                cformat!("  {}", text),
19        }
20    }
21    
22    pub fn url<P, S>(error: P, url: S) -> Error 
23    where 
24        P: Display,
25        S: Display,
26    {
27        make_error!{
28            etype!("url"), "Error parsing a url",
29            2 of 
30                cformat!("<y>* {}</>", error),
31                cformat!("  <b><<{}>></>", url),
32        }
33    }
34}