Skip to content

Instantly share code, notes, and snippets.

@DirkHoffmann
Created April 24, 2015 15:12
Show Gist options
  • Select an option

  • Save DirkHoffmann/8fb7b06310818cd12bf6 to your computer and use it in GitHub Desktop.

Select an option

Save DirkHoffmann/8fb7b06310818cd12bf6 to your computer and use it in GitHub Desktop.
Print UnicodeError nicely (and compactly)
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