[Python] Python Requests ProxyError not caught

Discussão em 'Python' iniciado por Stack, Fevereiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    Why would the proxy error not be caught by the first except: clause? I am not quite understanding why it is defaulting to the second clause (or if I remove the second cause it will just throw an error)

    from requests.exceptions import ProxyError

    try:
    login(acc)
    except ProxyError:
    pass
    except Exception as e:
    print e


    Output:

    HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: /mail (Caused by ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 403 Forbidden',)))

    Continue reading...

Compartilhe esta Página