How can I get the response object back from a request when it throws an exception? 

Essentially, I'm trying to make a request via a proxy and the proxy is giving back a 302 code (this is what I want). However, after some debugging, I discovered that inside the `requests` library, it expects a 200 code from the proxy and will throw an exception otherwise. 

Here is the command I'm executing: 

```
session.get(url=url, headers=req_headers, verify=False, allow_redirects=True, timeout=30)

```

This gives me a `(Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 302 Object Moved'))`. This is the correct behavior I'm expecting from my proxy but I need the response object because the response object has useful info that I need in my logic and right now I'm only able to get the error msg. Is there a way I can still get the response object without having to modify the `requests` library?

Thanks for your help!

Edit:

```
def _tunnel(self):
    connect_str = "CONNECT %s:%d HTTP/1.0\r\n" % (self._tunnel_host,
        self._tunnel_port)
    connect_bytes = connect_str.encode("ascii")
    self.send(connect_bytes)
    for header, value in self._tunnel_headers.items():
        header_str = "%s: %s\r\n" % (header, value)
        header_bytes = header_str.encode("latin-1")
        self.send(header_bytes)
    self.send(b'\r\n')

    response = self.response_class(self.sock, method=self._method)
    (version, code, message) = response._read_status()

    if code != http.HTTPStatus.OK:
        self.close()
        raise OSError("Tunnel connection failed: %d %s" % (code,
                                                           message.strip()))

```

I've debugged it such that I know that the code is throwing the OSError and it only gives the status code and the message. What I want to do is also pass in the `response` to that exception but at the same time I don't want to change the library because I'm hoping there's a way to do this without changing the lib