diff options
| author | Rapptz <[email protected]> | 2015-12-29 01:21:10 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2015-12-29 01:21:10 -0500 |
| commit | 7696a566e1b19b3a9367922ff5c03d286294079e (patch) | |
| tree | 16388cc84b94b2d4cc3c33eab7bffb6239cfa189 | |
| parent | Message no longer upgrades if the channel is an Object (diff) | |
| download | discord.py-7696a566e1b19b3a9367922ff5c03d286294079e.tar.xz discord.py-7696a566e1b19b3a9367922ff5c03d286294079e.zip | |
Raise ClientException if an unexpected websocket close happens
| -rw-r--r-- | discord/client.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/discord/client.py b/discord/client.py index 0f8df2d5..e77d3b71 100644 --- a/discord/client.py +++ b/discord/client.py @@ -698,13 +698,17 @@ class Client: Raises ------- ClientException - If this is called before :meth:`login` was invoked successfully. + If this is called before :meth:`login` was invoked successfully + or when an unexpected closure of the websocket occurs. """ yield from self._make_websocket() while not self.is_closed: msg = yield from self.ws.recv() if msg is None: + if self.connection is None: + raise ClientException('Unexpected websocket closure received') + if self.ws.close_code == 1012: yield from self.redirect_websocket(self.gateway) continue |