jturner314 / ndarray-npy

.npy and .npz file format support for ndarray
https://docs.rs/ndarray-npy
Apache License 2.0
56 stars 18 forks source link

Improve `WrongDescriptor` error message by printing the expected descriptor #71

Open flip1995 opened 1 year ago

flip1995 commented 1 year ago

Currently, when reading (or writing) an NPZ file and the type descriptor is not as expected, the error message only shows the descriptor that's in the NPZ file:

https://github.com/jturner314/ndarray-npy/blob/169c11649c3d27b83595c3b15d86c60133a9aac8/src/npy/mod.rs#L488-L490

This could be extended by , expected ({}) showing what descriptor was expected.

I don't know if every place in the code that produces a WrongDescriptor error also knows what the expected descriptor is though. So not sure how feasible this request is.