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

PyDruids clients throw to generic Exceptions OSError #263

Open
sebtrack opened this issue May 14, 2021 · 0 comments
Open

PyDruids clients throw to generic Exceptions OSError #263

sebtrack opened this issue May 14, 2021 · 0 comments

Comments

@sebtrack
Copy link

sebtrack commented May 14, 2021

The error handling does not allow to manage exceptions when using PyDruid. For example, it's hard to catch an HTTP Error 504: Gateway Time-out and then initiate a retry. A connection refused would, on the other hand, be an exception to log with Sentry, etc. All the fine-grained HTTP client exceptions get the generic label OSError with a string describing it, which is a bad design decision.

pydruid/pydruid/client.py

Lines 554 to 577 in 98cab4d

except urllib.error.HTTPError as e:
err = e.read()
if e.code == 500:
# has Druid returned an error?
try:
err = json.loads(err)
except ValueError:
if HTML_ERROR.search(err):
err = HTML_ERROR.search(err).group(1)
except (ValueError, AttributeError, KeyError):
pass
raise IOError(
"{0} \n Druid Error: {1} \n Query is: {2}".format(
e,
err,
json.dumps(
query.query_dict,
indent=4,
sort_keys=True,
separators=(",", ": "),
),
)
)

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