iro/error.py
branchdevel
changeset 116 48c70425bf6c
parent 110 601fc908d9f1
child 125 19b3f383c9ce
equal deleted inserted replaced
115:323d06431100 116:48c70425bf6c
    21 
    21 
    22 class ValidateException(Exception):
    22 class ValidateException(Exception):
    23     def __init__(self, code=700, field=None, msg=None):
    23     def __init__(self, code=700, field=None, msg=None):
    24         self.code=code
    24         self.code=code
    25         self.field=field
    25         self.field=field
    26         self.msg='Validation failed.'
    26         self.msg = msg
       
    27         if not msg:
       
    28             self.msg='Validation failed.'
    27         if field and not msg:
    29         if field and not msg:
    28             self.msg="Validation of '%s' failed."%field
    30             self.msg="Validation of '%s' failed."%field
    29 
    31 
    30     def dict(self):
    32     def dict(self):
    31         return {"code":self.code,
    33         return {"code":self.code,