Skip to content

Consider using multiple inheritance for exception hierarchy #45

@mimi89999

Description

@mimi89999

It would be helpful to have a common base exception that all proxy errors inherit from, so users can catch all proxy-related errors with a single except block when needed.

Currently, catching all proxy-related exceptions requires handling three separate exception types:

try:
    # proxy code
except (ProxyError, ProxyTimeoutError, ProxyConnectionError) as e:
    # handle error

This is because ProxyTimeoutError and ProxyConnectionError don't inherit from a common base exception.

Multiple inheritance could maintain compatibility with built-in exceptions while allowing a single catch block. This pattern is used by other libraries like aiohttp:

class InvalidUrlRedirectClientError(InvalidUrlClientError, RedirectClientError):
    """Invalid URL redirect client error."""

https://docs.aiohttp.org/en/stable/_modules/aiohttp/client_exceptions.html#InvalidUrlRedirectClientError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions