Add CommonVariableError

master3.3
Mike Hiretsky 12 years ago
parent 25addb055b
commit 4f3b35c757

@ -57,6 +57,9 @@ class VariableError(Exception):
class PasswordError(VariableError):
"""Exception of password change error"""
class CommonVariableError(VariableError):
"""Exception for command line"""
import cl_template
def makePath(dirs,mode=755):
@ -1493,10 +1496,14 @@ class DataVars(SimpleDataVars):
messages = e.message if type(e.message) == list \
else [e]
mess = "\n".join(map(lambda x:str(x),self.plainList(*messages)))
if isinstance(e,PasswordError) or \
type(e.message) == list and \
all(isinstance(x,PasswordError) for x in e.message):
typeError = 'pwderror'
mapError = {PasswordError:'pwderror',
CommonVariableError:'commonerror'}
for k,v in mapError.items():
if isinstance(e,k) or \
type(e.message) == list and \
all(isinstance(x,k) for x in e.message):
typeError = v
break
else:
typeError = 'error'
errors.append({'type':typeError, 'field':var, 'message':mess})

Loading…
Cancel
Save