Be more discerning in the exceptions that are caught, and show more info about exceptions when they happen.
The first issue is a bare except: will even catch the KeyboardInterrupt exception generated by ctrl-c, so sometimes you would have to press ctrl-c twice to stop the program. Now we except Exception:.
The second issue is that not much info was shown about an exception, which especially during development could make debugging difficult. Previously:
exception in loadmap()
<class 'selenium.common.exceptions.TimeoutException'>
With this change:
exception in Tweet():
Traceback (most recent call last):
File "tracker.py", line 227, in <module>
Tweet(a[0], havescreenshot)
File "tracker.py", line 90, in Tweet
tweet = Template(parser.get('tweet', 'tweet_template')).substitute(templateArgs)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/string.py", line 126, in substitute
return self.pattern.sub(convert, self.template)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/string.py", line 119, in convert
return str(mapping[named])
KeyError: 'dist'
Be more discerning in the exceptions that are caught, and show more info about exceptions when they happen.
The first issue is a bare
except:
will even catch theKeyboardInterrupt
exception generated by ctrl-c, so sometimes you would have to press ctrl-c twice to stop the program. Now weexcept Exception:
.The second issue is that not much info was shown about an exception, which especially during development could make debugging difficult. Previously:
With this change: