Fix handling exception
This commit is contained in:
@@ -118,13 +118,10 @@ class PytchatCore:
|
|||||||
except exceptions.ChatParseException as e:
|
except exceptions.ChatParseException as e:
|
||||||
self._logger.debug(f"[{self._video_id}]{str(e)}")
|
self._logger.debug(f"[{self._video_id}]{str(e)}")
|
||||||
self._raise_exception(e)
|
self._raise_exception(e)
|
||||||
except (TypeError, json.JSONDecodeError) as e:
|
except Exception as e:
|
||||||
self._logger.error(f"{traceback.format_exc(limit=-1)}")
|
self._logger.error(f"{traceback.format_exc(limit=-1)}")
|
||||||
self._raise_exception(e)
|
self._raise_exception(e)
|
||||||
|
|
||||||
self._logger.debug(f"[{self._video_id}]finished fetching chat.")
|
|
||||||
self._raise_exception(exceptions.ChatDataFinished)
|
|
||||||
|
|
||||||
def _get_contents(self, continuation, client, headers):
|
def _get_contents(self, continuation, client, headers):
|
||||||
'''Get 'continuationContents' from livechat json.
|
'''Get 'continuationContents' from livechat json.
|
||||||
If contents is None at first fetching,
|
If contents is None at first fetching,
|
||||||
@@ -201,7 +198,7 @@ class PytchatCore:
|
|||||||
raise self._exception_holder
|
raise self._exception_holder
|
||||||
|
|
||||||
def _raise_exception(self, exception: Exception = None):
|
def _raise_exception(self, exception: Exception = None):
|
||||||
self._is_alive = False
|
self.terminate()
|
||||||
if self._hold_exception is False:
|
if self._hold_exception is False:
|
||||||
raise exception
|
raise exception
|
||||||
self._exception_holder = exception
|
self._exception_holder = exception
|
||||||
|
|||||||
@@ -186,12 +186,12 @@ class LiveChatAsync:
|
|||||||
except exceptions.ChatParseException as e:
|
except exceptions.ChatParseException as e:
|
||||||
self._logger.debug(f"[{self._video_id}]{str(e)}")
|
self._logger.debug(f"[{self._video_id}]{str(e)}")
|
||||||
raise
|
raise
|
||||||
except (TypeError, json.JSONDecodeError):
|
except Exception:
|
||||||
self._logger.error(f"{traceback.format_exc(limit = -1)}")
|
self._logger.error(f"{traceback.format_exc(limit = -1)}")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
self._logger.debug(f"[{self._video_id}] finished fetching chat.")
|
self._logger.debug(f"[{self._video_id}] finished fetching chat.")
|
||||||
raise exceptions.ChatDataFinished
|
|
||||||
|
|
||||||
async def _check_pause(self, continuation):
|
async def _check_pause(self, continuation):
|
||||||
if self._pauser.empty():
|
if self._pauser.empty():
|
||||||
|
|||||||
@@ -179,12 +179,12 @@ class LiveChat:
|
|||||||
except exceptions.ChatParseException as e:
|
except exceptions.ChatParseException as e:
|
||||||
self._logger.debug(f"[{self._video_id}]{str(e)}")
|
self._logger.debug(f"[{self._video_id}]{str(e)}")
|
||||||
raise
|
raise
|
||||||
except (TypeError, json.JSONDecodeError):
|
except Exception:
|
||||||
self._logger.error(f"{traceback.format_exc(limit=-1)}")
|
self._logger.error(f"{traceback.format_exc(limit=-1)}")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
self._logger.debug(f"[{self._video_id}] finished fetching chat.")
|
self._logger.debug(f"[{self._video_id}] finished fetching chat.")
|
||||||
raise exceptions.ChatDataFinished
|
|
||||||
|
|
||||||
def _check_pause(self, continuation):
|
def _check_pause(self, continuation):
|
||||||
if self._pauser.empty():
|
if self._pauser.empty():
|
||||||
|
|||||||
Reference in New Issue
Block a user