Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Construct useful error objects/messages from unexpected response codes and errors #46

Open
kshepherd opened this issue Jan 30, 2025 · 1 comment

Comments

@kshepherd
Copy link
Collaborator

In fetch_resource and elsewhere, errors are handled in a pretty negligent way - a line is logged and None is returned, and things carry on...
But this does not allow the calling script to inspect what kind of error was encountered and what it needs to do to remedy / retry the failed fetch / search / whatever.

I think several things need to be improved:

  1. Look at the best way to model either Error objects or using Python exceptions, based on the error message like
{"timestamp":"2025-01-30T00:31:17.885+00:00",
"status":500,
"error":"Internal Server Error",
"message":"Unexpected error of some kind....",
"path":"/server/api/discover/search/objects"}
  1. Architecturally, change fetch_resource and all the calling functions to stop catching+logging, but either returning these Error objects somehow or raising new Exceptions based on the error thrown by fetch_resource so the caller can handle them

This would be a breaking change as most existing scripts using the library would be used to testing for None returns and reading log messages for error handling

@kshepherd
Copy link
Collaborator Author

@pnbecker suggested parallel methods to avoid breaking changes, if that is still a problem (it may not be - see notes of fetch_resource usage at #47).
Another way could be an optional parameter to all those methods like handle_errors=False, so the same methods can be used but callers can specifically turn ON the error handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant