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