From fed13cec6c5d9abe8dd6ae5d0b83f8efd9ae33b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20V=C3=BDboch?= <47027005+petereon@users.noreply.github.com> Date: Sun, 1 Sep 2024 20:05:42 +0200 Subject: [PATCH] Add clearer error message on module name conversion (#26) --- pyo3_bindgen_engine/src/syntax/module.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyo3_bindgen_engine/src/syntax/module.rs b/pyo3_bindgen_engine/src/syntax/module.rs index 2b2a39f..31fc78e 100644 --- a/pyo3_bindgen_engine/src/syntax/module.rs +++ b/pyo3_bindgen_engine/src/syntax/module.rs @@ -504,7 +504,13 @@ impl Module { }; // Finalize the module with its content - let module_ident: syn::Ident = self.name.name().try_into()?; + let module_ident: syn::Ident = self.name.name().try_into().map_err(|err| { + crate::PyBindgenError::CodegenError(format!( + "Failed to convert module name `{}` to identifier: {}", + self.name.name(), + err + )) + })?; output.extend(quote::quote! { pub mod #module_ident { #embed_source_code_fn