Skip to content

Commit 6d74e43

Browse files
yuraizbilelmoussaoui
authored andcommitted
gtk4-macros: Use abort_call_site instead of panic
1 parent 6ce4d65 commit 6d74e43

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

gtk4-macros/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ use syn::{parse_macro_input, DeriveInput};
2020
/// It expected to run inside composite_template_derive, not by users
2121
#[cfg(feature = "blueprint")]
2222
#[proc_macro]
23+
#[proc_macro_error]
24+
#[doc(hidden)]
2325
pub fn include_blueprint(input: TokenStream) -> TokenStream {
26+
use proc_macro_error::abort_call_site;
2427
use quote::quote;
2528

2629
let tokens: Vec<_> = input.into_iter().collect();
2730

2831
if tokens.len() != 1 {
29-
panic!("File name not found");
32+
abort_call_site!("File name not found");
3033
}
3134

3235
let root = std::env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".into());
@@ -38,14 +41,14 @@ pub fn include_blueprint(input: TokenStream) -> TokenStream {
3841
let path = std::path::Path::new(&root).join(file_name);
3942

4043
if !path.exists() {
41-
panic!("{path:?} not found");
44+
abort_call_site!("{} not found", &path.to_string_lossy());
4245
}
4346

4447
let path = path.to_string_lossy().to_string();
4548

4649
let template = blueprint::compile_blueprint(
4750
std::fs::read_to_string(&path)
48-
.unwrap_or_else(|err| panic!("{err}"))
51+
.unwrap_or_else(|err| abort_call_site!("{}", err))
4952
.as_bytes(),
5053
)
5154
.unwrap();

0 commit comments

Comments
 (0)