brisk_it/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//! Convenient function to generate errors

/// Errors that are caused by bugs.
pub fn impossible(span: proc_macro2::Span) -> proc_macro2::TokenStream {
    return syn::Error::new(span, "Impossible error.")
        .into_compile_error()
        .into();
}

/// Errors used for unknown properties
pub fn unknown_property(prop: crate::component::PropertyValue) -> proc_macro2::TokenStream {
    return syn::Error::new(prop.name.span(), format!("Unknown property {}", prop.name))
        .into_compile_error()
        .into();
}

/// Errors used for missing required properties
pub fn missing_property(component_name: &syn::Ident, prop_name: &str) -> proc_macro2::TokenStream {
    return syn::Error::new(
        component_name.span(),
        format!("Missing required property '{}'", prop_name),
    )
    .into_compile_error()
    .into();
}