Improve ocrd-network-client error handling#1337
Merged
Merged
Conversation
kba
reviewed
Sep 10, 2025
kba
requested changes
Sep 10, 2025
kba
left a comment
Member
There was a problem hiding this comment.
Thanks, I appreciate better error messages, we just have to make sure that no information gets lost with transforming assertions to proper exceptions and the assertions that remain are properly labelled.
kba
reviewed
Sep 18, 2025
| try: | ||
| processors_list = client.check_deployed_processors() | ||
| except RequestException as e: | ||
| print(f"{getattr(e, 'detail_message', str(e))}") |
Member
There was a problem hiding this comment.
Suggested change
| print(f"{getattr(e, 'detail_message', str(e))}") | |
| print(getattr(e, 'detail_message', str(e))) |
The f-string is unnecessary.
Member
There was a problem hiding this comment.
Where is e.detail_message defined? I don't see it in the requests.RequestException source code https://github.com/psf/requests/blob/420d16bc7ef326f7b65f90e4644adc0f6a0e1d44/src/requests/exceptions.py#L12
Contributor
Author
There was a problem hiding this comment.
Self defined in the other file in method _raise_if_error. This is the way to get the detail-message into the exception to print it afterwards to the user
Co-authored-by: Konstantin Baierer <kba@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Error handling by the OCR-D-network-client is currently based on assertions. If the requests to the processing server do not return a HTTP 200 code, the program fails. However, it does so without displaying the cause of the error. I have now changed this so that the error message is read from the HTTP-server-response and displayed.
Testing: To test this, you need a running OCR-D network, which can be started with this ocrd-all PR 468
Then make a request with the client, for example:
ocrd network client processing run --address http://localhost:8000 ocrd-dummy -I DEFAULT -O MY-OUTPUT. The path to the metsfile is missing which causes an error here. Currently, the output is as follows:AssertionError: Processing server: http://localhost:8000/processor/run/ocrd-dummy, 404This has now been changed and following error message is displayed:
Mets file path not existing: mets.xml Cannot create DB workspace entry, `mets.xml` does not exist!. The error-message are generated by the processing server and they are forwarded to the caller with this PR.