EvolEcolGroup / pastclim

An R package providing helper functions to interact with timeseries of worldwide climate reconstructions
https://evolecolgroup.github.io/pastclim/
Creative Commons Attribution 4.0 International
35 stars 3 forks source link

Improve error handling of dataset names in region_series #56

Closed japilo closed 1 month ago

japilo commented 1 month ago

I was running into some issues with names of subdatasets for region_series, so I implemented a couple of changes to improve it.

Issue 1: Uninformative error message in location_slice_from_region_series

I used this function and it threw a very uninformative error message. I tracked down the source of the error, and it was because the SpatRasterDataset I entered for the region_series argument did not have proper names for the subdatasets. I have added an informative error message that informs users if the names of region_series are invalid.

Issue 2: Uninformative error messages in slice_region_series

I also got an uninformative error message in the case when the subdatasets of region_series have improper varnames. I have added an informative error message that informs users if the varnames of region_series are invalid.

dramanica commented 1 month ago

Thank @japilo! Would you be able to add a unit test to show when this check comes into play? Thank you for your help with the package!

japilo commented 1 month ago

I have added unit tests that demonstrate situations where I faced uninformative error messages previously, and now get informative error messages. I also added tests for the error handling that was already built into the function because I noticed they didn't have test coverage yet.

dramanica commented 1 month ago

Brilliant, thank you @japilo!!! (only one minor request, in the future, can you please work off dev rather than master?)