splunk-sdk-python
splunk-sdk-python copied to clipboard
Splunk _handle_auth_error masks authentication errors as login errors
@contextmanager
def _handle_auth_error(msg):
"""Handle reraising HTTP authentication errors as something clearer.
If an ``HTTPError`` is raised with status 401 (access denied) in
the body of this context manager, reraise it as an
``AuthenticationError`` instead, with *msg* as its message.
This function adds no round trips to the server.
:param msg: The message to be raised in ``AuthenticationError``.
:type msg: ``str``
**Example**::
with _handle_auth_error("Your login failed."):
... # make an HTTP request
"""
try:
yield
except HTTPError as he:
if he.status == 401:
raise AuthenticationError(msg, he)
else:
raise
@SyraD - thanks for the bug report! We're now tracking this internally. We appreciate your help with identifying and fixing these issues.
@SyraD we have updated the error message. The change will be available in the next release. Refer the change
@SyraD we would request you to use the latest SDK release with the change implemented. Thanks!