Changed format of TypeError messages

This commit is contained in:
R2D2 2021-05-27 22:36:19 +02:00
parent f68ab481ba
commit d71d4329ae
1 changed files with 4 additions and 4 deletions

View File

@ -245,17 +245,17 @@ impl<'a> Container<'a> {
let get_field = quote!(obj.#getter?);
let extractor = match &attrs.from_py_with {
None => quote!(#get_field.extract().map_err(|inner| {
let err_msg = format!("Failed to extract field {} of {}:\n{} ",
stringify!(#ident),
let err_msg = format!("failed to extract field {}.{}\n\nCaused by:\n {}\n",
stringify!(#self_ty),
stringify!(#ident),
inner);
pyo3::exceptions::PyTypeError::new_err(err_msg)
})?),
Some(FromPyWithAttribute(expr_path)) => quote! (#expr_path(#get_field).
map_err(|inner| {
let err_msg = format!("Failed to extract field {} of {}:\n{} ",
stringify!(#ident),
let err_msg = format!("failed to extract field {}.{}\n\nCaused by:\n {}\n",
stringify!(#self_ty),
stringify!(#ident),
inner);
pyo3::exceptions::PyTypeError::new_err(err_msg)
})?),