natverse / rcatmaid

R package providing API access to the CATMAID web image annotation tool
https://natverse.github.io/rcatmaid
GNU General Public License v3.0
9 stars 6 forks source link

New CATMAID error handling #142

Open clbarnes opened 5 years ago

clbarnes commented 5 years ago

As of https://github.com/catmaid/CATMAID/pull/1923 (not released at time of writing), the CATMAID server will return meaningful status codes on errors. The response content still contains the same JSON-serialised exception info, but the status code will no longer be 200. Generally, it will be 500, unless the server raised a ValueError (assumed to be the result of bad inputs, so it's 400), or the user had insufficient privileges (401).

This is a warning that you may need to update your fetch layer (although hopefully it's a welcome change!). Thanks @tomka for making the change.

Tracking issue here: https://github.com/catmaid/CATMAID/issues/1921

jefferis commented 5 years ago

Thanks @clbarnes. What should I expect to get back? An appropriate error code with a body containing the detailed error message as json? Is there can example somewhere? AFAICS the rcatmaid code will continue to run fine, but may not print the detailed error message properly.

clbarnes commented 5 years ago

The response body is exactly the same as it was before - a JSON object containing the error type, message, and traceback. All that's changing is the status code, which will now be 400, 401 or 500 as appropriate when the backend raises an exception. Presumably rcatmaid currently just ignores the status code as it's not informative, so I wouldn't expect this change to break anything; however, going forward you'll have the option of checking the status code to detect an error response, instead of having to parse the JSON and check its contents.

clbarnes commented 5 years ago

Just for documentation purposes: https://github.com/catmaid/CATMAID/commit/3b49a435275f3ee0c5e1a2c17a7ef24558df912e breaks rcatmaid compatibility; https://github.com/catmaid/CATMAID/commit/1ac3845724e858fdc87274ec93d1b0f661e0bc74 fixes it again. Both are only in dev currently, the next release will include both.

The neurocean catmaidL1 instance we run has been updated with the fix (thanks to Michael Winding for catching this).

jefferis commented 5 years ago

Just a note that right now an http error code would trigger an immediate exception without parsing the catmaid error message. Some change will be required to continue to print informative error messages.