Duke-GCB / D4S2

Web service to facilitate notification and transfer of projects in DukeDS
MIT License
0 stars 0 forks source link

Clean up d4s2_api_v2.api.DDSViewSet exception handling #206

Closed dleehr closed 5 years ago

dleehr commented 5 years ago

In d4s2_api_v2/api.py, we have a WrappedDataServiceException class that is caught but never actually raised:

https://github.com/Duke-GCB/D4S2/blob/2f6a5f3f30bbb0f70d097c2a4d879db7c765f8a6/d4s2_api_v2/api.py#L25-L31

The base DDSViewSet class is designed to catch these so that API clients get meaningful HTTP response codes from failed DDS operations. However, in practice, exceptions of this class are never raised and everything is transformed to a 503 with DataServiceUnavailable

https://github.com/Duke-GCB/D4S2/blob/2f6a5f3f30bbb0f70d097c2a4d879db7c765f8a6/d4s2_api_v2/api.py#L58-L67

Fix this to catch DataServiceErrors and wrap them in WrappedDataServiceException in a way that preserves the correct status code.