Skip to content
This repository was archived by the owner on Jun 22, 2022. It is now read-only.
This repository was archived by the owner on Jun 22, 2022. It is now read-only.

Passing code review #46

@amingilani

Description

@amingilani

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions