ImagingDataCommons / dicomweb-client

Python client for DICOMweb RESTful services
https://dicomweb-client.readthedocs.io
MIT License
110 stars 38 forks source link

Unify exceptions between web and file clients #69

Closed hackermd closed 2 years ago

hackermd commented 2 years ago

This PR introduces changes to unify exceptions between DICOMwebClient and DICOMfileClient. Specifically, it ensures that errors that would result in requests.HTTPError exceptions in DICOMwebClient are handled the same way by DICOMfileClient, including HTTP status codes to differentiate between client (4XX) and server (5XX) errors.

It is a bit weird for DICOMfileClient to raise requests.HTTPError, because the client does not rely on HTTP. Ultimately, it would probably be nice to fully abstract the error handling logic via a custom exception class. However, that would break existing behavior of the DICOMwebClient. It's something we could consider for version 1.0.