Aestate
__init__.py
Go to the documentation of this file.
1 import re
2 import traceback
3 from enum import Enum
4 
5 
6 class DBException(Exception):
7  def __init__(self, baseException):
8  self.baseException = baseException
9  self.baseName = self.baseException.__class__.__name__
10  super(DBException, self).__init__()
11 
12  def __str__(self):
13  return f"({self.baseName}):{str(self.baseException)}"
14 
15 
16 class ModuleCreateError(ModuleNotFoundError):
17  """模块创建异常"""
18 
19 
20 class FieldNotExist(AttributeError):
21  """字段不存在"""
22 
23 
25  """sql返回错误"""
26 
27 
28 class XmlParseError(Exception):
29  """xml解析错误"""
30 
31 
33  """找不到xml模板"""
34 
35 
37  """节点属性错误"""
38 
39 
41  """节点处理方式错误"""
42 
43 
45  def __init__(self, exception):
46  self.exception = exception
47  self.text = str(exception)
48 
49  def ver(self):
50  return self.text
51 
52  def raise_exception(self, **kwargs):
53  ar = self.exception.args
54  ar_array = list(ar)
55  ar_array[len(ar_array) - 1] = self.text
56  self.exception.args = ar_array
57  raise DBException(self.exception)
58 
59 
61  def __init__(self, text):
62  self.text = text
63  self.err_text = text
64 
65  def syntax_error(self):
66  flag = re.compile("You have an error in your SQL syntax[\w\W].*use near([\w\W].*)")
67  err_content = flag.findall(self.text)
68  if err_content:
69  self.err_text = "sql statement spelling error, wrong content:(%s)" % err_content[0]
70  return self.err_text
71 
72  def format_err(self):
73  flag = re.compile(".*not all arguments converted during string formatting.*")
74  err_content = flag.findall(self.text)
75  if err_content:
76  self.err_text = "The parameter does not correspond to the number of formatted strings:(%s)" % err_content[0]
77  return self.err_text
78 
79 
81 
82  def ver(self):
83  mer = MySqlErrorRegular(self.text)
84  mer.syntax_error()
85  mer.format_err()
86  self.text = mer.err_text
87  return self.text
88 
89 
90 class LogStatus(Enum):
91  Error = 'ERROR'
92  Warn = 'WARN'
93  Info = 'INFO'
aestate.exception.DBException
Definition: __init__.py:6
aestate.exception.BaseMySqlError.raise_exception
def raise_exception(self, **kwargs)
Definition: __init__.py:52
aestate.exception.DBException.baseException
baseException
Definition: __init__.py:8
aestate.exception.DBException.__init__
def __init__(self, baseException)
Definition: __init__.py:7
aestate.exception.MySqlErrorRegular.err_text
err_text
Definition: __init__.py:63
aestate.exception.MySqlErrorRegular.format_err
def format_err(self)
Definition: __init__.py:72
aestate.exception.TagHandlerError
Definition: __init__.py:40
aestate.exception.LogStatus
Definition: __init__.py:90
aestate.exception.BaseMySqlError
Definition: __init__.py:44
aestate.exception.TagAttributeError
Definition: __init__.py:36
aestate.exception.ModuleCreateError
Definition: __init__.py:16
aestate.exception.BaseMySqlError.ver
def ver(self)
Definition: __init__.py:49
aestate.exception.MySqlErrorRegular.__init__
def __init__(self, text)
Definition: __init__.py:61
aestate.exception.MySqlErrorRegular
Definition: __init__.py:60
aestate.exception.SqlResultError
Definition: __init__.py:24
aestate.exception.DBException.baseName
baseName
Definition: __init__.py:9
aestate.exception.BaseMySqlError.__init__
def __init__(self, exception)
Definition: __init__.py:45
aestate.exception.BaseMySqlError.exception
exception
Definition: __init__.py:46
aestate.exception.MySqlErrorRegular.text
text
Definition: __init__.py:62
aestate.exception.MySqlErrorTest.ver
def ver(self)
Definition: __init__.py:82
aestate.exception.NotFindTemplateError
Definition: __init__.py:32
aestate.exception.XmlParseError
Definition: __init__.py:28
aestate.exception.MySqlErrorRegular.syntax_error
def syntax_error(self)
Definition: __init__.py:65
aestate.exception.MySqlErrorTest
Definition: __init__.py:80
aestate.exception.DBException.__str__
def __str__(self)
Definition: __init__.py:12
aestate.exception.BaseMySqlError.text
text
Definition: __init__.py:47