biigle / core

:large_blue_circle: Application core of BIIGLE
https://biigle.de
GNU General Public License v3.0
12 stars 16 forks source link

Handle WoRMS errors more gracefully #441

Closed mzur closed 1 year ago

mzur commented 2 years ago

WoRMS is in maintenance mode at the moment. This produces a SoapFault error here, which is not caught. Handle these kinds of errors more gracefully and return a "WoRMS is currently unavailable" response (maybe even code 503?).

mzur commented 1 year ago

Clarification: WoRMS can be used to import labels from the external WoRMS database into a label tree:

Screen Shot 2023-06-02 at 09 04 57

mzur commented 1 year ago

@lehecht I have to reopen this issue because the error also appeared at this location:

https://github.com/biigle/core/blob/b370415195a05e845fe59daa10ccb1be4267dc2e/app/Http/Controllers/Api/LabelTreeLabelController.php#L50

It also occurred to me that the SoapFault is specific to the WoRMS adapter because other adapters might not use SOAP at all. So it's probably better to handle the exception directly in the adapter.

Here:

https://github.com/biigle/core/blob/b370415195a05e845fe59daa10ccb1be4267dc2e/app/Services/LabelSourceAdapters/WormsAdapter.php#L142-L158

By wrapping the whole block in a try/catch and throwing a Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException with an appropriate message.

And here:

https://github.com/biigle/core/blob/b370415195a05e845fe59daa10ccb1be4267dc2e/app/Services/LabelSourceAdapters/WormsAdapter.php#L91

By also throwing a ServiceUnavailableHttpException with the message.

You should revert #595 and add new test cases to WormsAdapterTest.