Skip to content

Instantly share code, notes, and snippets.

@andreastt
Created July 20, 2020 12:19
Show Gist options
  • Save andreastt/100c3bde91b1305a307af5a017b97e00 to your computer and use it in GitHub Desktop.
Save andreastt/100c3bde91b1305a307af5a017b97e00 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import six
class FooException(Exception):
def __init__(self, message):
if six.PY2 and isinstance(message, six.text_type):
super(FooException, self).__init__(message.encode("utf-8"))
else:
super(FooException, self).__init__(message)
def __unicode__(self):
return str(self).decode("utf-8")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment