jumpserver-python-sdk
jumpserver-python-sdk copied to clipboard
Passing code review
Hello,
I was just passing by and discovered these lines:
except (requests.ConnectionError, requests.ConnectTimeout) as e:
msg = "Connect endpoint {} error: {}".format(self.endpoint, e)
logger.error(msg)
raise RequestError(msg)
I just wanted to let you know that you can use from
which allows exception chaining with a customer exception. Essentially allowing you to do this:
class HttpError(Exception):
"""Base class for all HTTP exceptions"""
class EndpointError(Exception):
pass
except (requests.ConnectionError, requests.ConnectTimeout) as e:
raise EndpointError(f"Connect endpoint for {self.endpoint}") from e
And catch it from a higher layer.