Add error handling to python example

Checking for the exceptions supplied by PyJWT seems cleaner.