Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception occurred cannot unpack non-iterable NoneType object #149

Closed
Mte90 opened this issue Apr 8, 2019 · 5 comments
Closed

Exception occurred cannot unpack non-iterable NoneType object #149

Mte90 opened this issue Apr 8, 2019 · 5 comments

Comments

@Mte90
Copy link

Mte90 commented Apr 8, 2019

Command used packt-cli -g
Output in log

[ERROR] - Fetching JWT token failed!
[INFO] - Start grabbing ebook...
[ERROR] - Exception occurred cannot unpack non-iterable NoneType object
@mjenczmyk
Copy link
Collaborator

You failed to log into Packt API - are you sure your credentials in configuration file are correct?

@Mte90
Copy link
Author

Mte90 commented Apr 9, 2019

You were right, maybe add a better error can be more helpful for the next one :-D

@mjenczmyk
Copy link
Collaborator

We could exit from the script when fetching JWT fails, so the script doesn't break on confusing error (see diff below). What do you think?

diff --git a/src/api.py b/src/api.py
index 25be796..6576e02 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
 
@@ -38,6 +39,7 @@ class PacktAPIClient:
             logger.info('JWT token has been fetched successfully!')
         except Exception:
             logger.error('Fetching JWT token failed!')
+            sys.exit(1)
 
     def request(self, method, url, **kwargs):
         """Make a request to a Packt API."""

@Mte90
Copy link
Author

Mte90 commented Apr 9, 2019

seems a good idea but maybe add in the error also: "check your login settings before try again" can be helpful.

@mjenczmyk
Copy link
Collaborator

See #150 if it looks right.

@luk6xff luk6xff closed this as completed Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants