Closed arcanearronax closed 4 years ago
Sorry for the delayed response BTW, I was busy with some school work
Do you think having a dict of status codes, instead of a bunch of STATUS_
variables will be better? Because then this will be easily extendable in the future for adding more codes, and we only need to import something like a STATUS_CODES
dict
It's totally fine to keep it as is if you don't want to change it though, because search_error()
kind of acts as a 'dict' here, the only downside is we need to import a lot of variables
You're right about using a dict rather than creating a handful of variables, and it'll be able to scale easier. I'm not sure why I didn't think of it at the time. I'll get the changes made here in a bit.
Added error handling based on HTTP status codes. The status codes identified after submitting the GET request for the URL will produce a handling code which informs the cli method how it should proceed, either exiting the application or retrying the request. A message will be displayed to inform the user of the nature of the error or that a retry will occur in a given amount of time.
Context This will prevent errors originating from unsuccessful requests from reaching the user.
Description
Added a request validation method to search.py which both search and search_github_trending call when submitting a GET request. This will catch a connection error and raise an assertion error in the case of an HTTP status code indicating something other than a success. Added a search_error method which processes the assertion error and returns the appropriate handling code for the assertion error.
A while loop has been added to the cli method which contains the calls to search and search_github_trending in order to allow requests to be resubmitted (if appropriate) and messages are printed for the user to indicate the nature of the issue, based on the handling code.