Queer European MD passionate about IT
Browse Source

Catch and return unexpected exceptions during API calls

Davte 5 years ago
parent
commit
72a7dd5a5f
2 changed files with 6 additions and 3 deletions
  1. 1 1
      davtelepot/__init__.py
  2. 5 2
      davtelepot/api.py

+ 1 - 1
davtelepot/__init__.py

@@ -14,7 +14,7 @@ __author__ = "Davide Testa"
 __email__ = "davide@davte.it"
 __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
 __license__ = "GNU General Public License v3.0"
-__version__ = "2.2.7"
+__version__ = "2.2.8"
 __maintainer__ = "Davide Testa"
 __contact__ = "t.me/davte"
 

+ 5 - 2
davtelepot/api.py

@@ -298,12 +298,15 @@ class TelegramBot(object):
                             "request"
                         )
                         self.set_flood_wait(flood_wait)
-                    return e
+                    response_object = e
                 except Exception as e:
                     logging.error(f"{e}", exc_info=True)
-                    return e
+                    response_object = e
         except asyncio.TimeoutError as e:
             logging.info(f"{e}: {method} API call timed out")
+        except Exception as e:
+            logging.info(f"Unexpected eception:\n{e}")
+            response_object = e
         finally:
             if session_must_be_closed and not session.closed:
                 await session.close()