Created
April 24, 2015 15:12
-
-
Save DirkHoffmann/8fb7b06310818cd12bf6 to your computer and use it in GitHub Desktop.
Print UnicodeError nicely (and compactly)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def enniceUnicodeError(ex): | |
| return "<{0}>: {1}".format(ex.__class__.__name__, str(ex)) | |
| if __name__ == '__main__': | |
| /* Make dummy exception */ | |
| ux=UnicodeDecodeError('hitchhiker', b"", 42, 43, 'the universe and everything else') | |
| /* This is how to use the method : */ | |
| print enniceUnicodeError(ux) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment