Skip to content

[FEATURE] More fine grained network exceptions #3778

@Bibo-Joshi

Description

@Bibo-Joshi

What kind of feature are you missing? Where do you notice a shortcoming of PTB?

We currently only have NetworkError and TimeoutError(NetworkError) to indicate exceptions that are due to natworking problems (in contrast to exceptions issued by TG). This is not very fine grained and can make advanced exception handling difficult.

Describe the solution you'd like

I'd like to add more subclasses. Looking it httpx, they have a large number of them. Not all of them add much value for us IMO. In the following I list all of the httpx excetpions and check the ones that I think would make sense to have for us:

  • HTTPError
    • RequestError
      • TransportError
        • TimeoutException ( (corresponds to tg.TimeoutError)
          • ConnectTimeout
          • ReadTimeout
          • WriteTimeout
          • PoolTimeout
        • NetworkError (corresponds to tg.NetworkError)
          • ConnectError
          • ReadError
          • WriteError
          • CloseError
        • ProtocolError
          • LocalProtocolError
          • RemoteProtocolError
        • ProxyError
        • UnsupportedProtocol
      • DecodingError
      • TooManyRedirects
    • HTTPStatusError
  • InvalidURL
  • CookieConflict
  • StreamError
    • StreamConsumed
    • StreamClosed
    • ResponseNotRead
    • RequestNotRead

Describe alternatives you've considered

No response

Additional context

No response

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