FlightDeck/utils/exceptions.py

22 строки
573 B
Python
Исходник Обычный вид История

from django.template.defaultfilters import escape
2011-02-03 14:03:01 +03:00
class SimpleException(Exception):
" Exception extended with a value "
def __init__(self, value):
self.value = value
super(SimpleException, self).__init__()
def __str__(self):
return repr(self.value)
def parse_validation_messages(err):
error = ''
2011-12-13 16:11:10 +04:00
if not hasattr(err, 'message_dict'):
return str(err)
for field, msgs in err.message_dict.items():
error += ("%s: " % field)
for msg in msgs:
error += ("%s " % escape(msg))
return error