Fix handling exception

This commit is contained in:
taizan-hokuto
2020-01-02 21:14:22 +09:00
parent 18400724b1
commit 0fc9d14780

View File

@@ -9,7 +9,8 @@ from .. import config
from .. exceptions import ( from .. exceptions import (
ResponseContextError, ResponseContextError,
NoContentsException, NoContentsException,
NoContinuationsException ) NoContinuationsException,
ChatParseException )
logger = config.logger(__name__) logger = config.logger(__name__)
@@ -22,7 +23,7 @@ class Parser:
def get_contents(self, jsn): def get_contents(self, jsn):
if jsn is None: if jsn is None:
return {'timeoutMs':0,'continuation':None},[] raise ChatParseException('Called with none JSON object.')
if jsn['response']['responseContext'].get('errors'): if jsn['response']['responseContext'].get('errors'):
raise ResponseContextError('The video_id would be wrong, or video is deleted or private.') raise ResponseContextError('The video_id would be wrong, or video is deleted or private.')
contents=jsn['response'].get('continuationContents') contents=jsn['response'].get('continuationContents')