2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 04:48:06 +00:00

More readable exception handling

This commit is contained in:
Dan 2018-04-03 11:40:08 +02:00
parent 2f2a381686
commit e69fea4bb5

View File

@ -802,15 +802,15 @@ class Client:
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
if self.is_started: if not self.is_started:
r = self.session.send(data) raise ConnectionError("Client has not been started")
self.fetch_peers(getattr(r, "users", [])) r = self.session.send(data)
self.fetch_peers(getattr(r, "chats", []))
return r self.fetch_peers(getattr(r, "users", []))
else: self.fetch_peers(getattr(r, "chats", []))
raise ConnectionError("client '{}' is not started".format(self.session_name))
return r
def load_config(self): def load_config(self):
parser = ConfigParser() parser = ConfigParser()