diff --git a/zulip_bots/zulip_bots/bots/youtube/test_youtube.py b/zulip_bots/zulip_bots/bots/youtube/test_youtube.py index 961c1c9..6273d4b 100644 --- a/zulip_bots/zulip_bots/bots/youtube/test_youtube.py +++ b/zulip_bots/zulip_bots/bots/youtube/test_youtube.py @@ -39,7 +39,7 @@ class TestYoutubeBot(BotTestCase): with self.mock_config_info({'key': 'somethinginvalid', 'number_of_results': '5', 'video_region': 'US'}), \ self.mock_http_conversation('test_invalid_key'), \ - self.assertRaises(SystemExit) as se: # type: ignore + self.assertRaises(bot_handler.BotQuitException): bot.initialize(bot_handler) def test_multiple(self) -> None: diff --git a/zulip_bots/zulip_bots/bots/youtube/youtube.py b/zulip_bots/zulip_bots/bots/youtube/youtube.py index 6404163..200ca7a 100644 --- a/zulip_bots/zulip_bots/bots/youtube/youtube.py +++ b/zulip_bots/zulip_bots/bots/youtube/youtube.py @@ -31,9 +31,8 @@ class YoutubeHandler(object): search_youtube('test', self.config_info['key'], self.config_info['video_region']) except HTTPError as e: if (e.response.json()['error']['errors'][0]['reason'] == 'keyInvalid'): - logging.error('Invalid key.' - 'Follow the instructions in doc.md for setting API key.') - sys.exit(1) + bot_handler.quit('Invalid key.' + 'Follow the instructions in doc.md for setting API key.') else: raise except ConnectionError: