class ParseError(Exception): def __init__(self, message): from django.utils.functional import Promise "ParseError can be passed a string or a list." if isinstance(message, list): self.messages = message else: assert isinstance(message, (basestring, Promise)), ("%s should be a string" % repr(message)) self.messages = [message] def __str__(self): return str(self.messages)