fixed rare issue with catching exceptions

master
parent b3190612bf
commit 710c4c0bcc

@ -69,14 +69,29 @@ class CriticalError(Exception):
class DataVarsError(Exception):
"""Exception of getting variable values"""
exception_list=None
def __init__(self, expression):
if isinstance(expression, list):
super().__init__("")
self.exception_list = expression
else:
super().__init__(expression)
class ImportModuleDataVarsError(DataVarsError):
"""Ошибка импортирования модуля"""
class VariableError(Exception):
"""Exception of sended by Variable"""
exception_list=None
def __init__(self, expression):
if isinstance(expression, list):
super().__init__("")
self.exception_list = expression
else:
super().__init__(expression)
class PasswordError(VariableError):
@ -1970,15 +1985,16 @@ class DataVars(SimpleDataVars):
raise VariableError(uncomperr)
except (VariableError, DataVarsError) as e:
# assemble all variable errors
messages = e if type(e) == list \
else [e]
# messages = e if type(e) == list \
# else [e]
messages = e.exception_list if e.exception_list else [e]
mess = "\n".join((str(x) for x in messages))
mapError = {PasswordError: 'pwderror',
CommonVariableError: 'commonerror'}
for k, v in mapError.items():
if (isinstance(e, k) or type(e) == list and
if (isinstance(e, k) or e.exception_list and
all(isinstance(x, k) for x in
e)):
e.exception_list)):
typeError = v
break
else:

@ -37,7 +37,7 @@ class dovecot(bind):
# разделитель названия и значения переменной
reSeparator = re.compile("\s*=\s*")
def postXML(self, xmlArea=False):
def postXML(self, xmlArea=None):
"""Последующая постобработка XML"""
# Добавляем перевод строки если его нет в конец области
if not xmlArea:

Loading…
Cancel
Save