From 154b1dccacee147422f7dc1fdf69a9e573c5a7df Mon Sep 17 00:00:00 2001 From: Marcin Jenczmyk Date: Tue, 9 Apr 2019 11:54:16 +0200 Subject: [PATCH] Exit script on failed JWT fetch --- src/api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api.py b/src/api.py index 25be796..f2b1752 100644 --- a/src/api.py +++ b/src/api.py @@ -1,5 +1,6 @@ """Module with Packt API client handling API's authentication.""" import logging +import sys import requests @@ -37,7 +38,8 @@ def fetch_jwt(self): self.session.headers.update({'authorization': 'Bearer {}'.format(jwt)}) logger.info('JWT token has been fetched successfully!') except Exception: - logger.error('Fetching JWT token failed!') + logger.error('Fetching JWT token failed! Check your login credentials.') + sys.exit(1) def request(self, method, url, **kwargs): """Make a request to a Packt API."""