inveniosoftware / datacite

Python API wrapper for the DataCite API.
https://datacite.readthedocs.io
Other
27 stars 33 forks source link

Handling of 422 Unprocessable Entity #89

Open dojobo opened 2 months ago

dojobo commented 2 months ago

Attempting to POST an already registered DOI to DataCite results in a 422 Unprocessable Entity. However, DataCiteError (defined in errors.py) does not have a case for this scenario, so such a response ends up being cast as a DataCiteServerError, which is meant for 5xx responses. In other words, a user error is converted into a server error.

dojobo commented 2 months ago

I think there should be an additional elif statement which checks for 4xx codes, prior to else: return DataCiteError(). Of course, there could also be a statement to check for 422 specifically.

tmorrell commented 2 months ago

Thanks for the report! I think we should be able to add this before we do the next release sometime in August. Pull requests are always welcome and make the process go a bit faster.