146 lines
4.0 KiB
Python
146 lines
4.0 KiB
Python
DB_OPEN_ERROR = 0
|
|
DB_FULL_ERROR = 1
|
|
DB_LONG_QUERY_ERROR = 2
|
|
DB_QUERY_ERROR = 3
|
|
DB_UNKNOWN_ERROR = 4
|
|
INTERNET_ERROR = 5
|
|
OUT_DATED_CRAWLER = 6
|
|
DELETED_URL_ERROR = 7
|
|
BLOCK_ERROR = 8
|
|
TIMEOUT = 9
|
|
NO_PROGRAM = 10
|
|
UNKNOWN_ERROR = 11
|
|
|
|
error_message = [
|
|
"DB_OPEN_ERROR",
|
|
"DB_FULL_ERROR",
|
|
"DB_LONG_QUERY_ERROR",
|
|
"DB_QUERY_ERROR",
|
|
"DB_UNKNOWN_ERROR",
|
|
"INTERNET_ERROR",
|
|
"OUT_DATED_CRAWLER",
|
|
"DELETED_URL_ERROR",
|
|
"BLOCK_ERROR",
|
|
"TIMEOUT",
|
|
"NO_PROGRAM",
|
|
"UNKNOWN_ERROR",
|
|
]
|
|
|
|
error_message_code = [
|
|
"e000",
|
|
"e001",
|
|
"e002",
|
|
"e003",
|
|
"e004",
|
|
"e005",
|
|
"e006",
|
|
"e007",
|
|
"e008",
|
|
"e009",
|
|
"e010",
|
|
"e011",
|
|
]
|
|
|
|
SEPERATOR = '!@#'
|
|
|
|
|
|
class EffectException(Exception):
|
|
def __init__(self, error_no, msg='', *args, **kwargs):
|
|
self.error_no = error_no
|
|
self.error_message_code = error_message_code[self.error_no]
|
|
self.msg = msg
|
|
Exception.__init__(self, *args, **kwargs)
|
|
|
|
def __str__(self):
|
|
try:
|
|
s = self.error_message_code + SEPERATOR + self.msg
|
|
except Exception as e:
|
|
print(e)
|
|
return s
|
|
|
|
|
|
class DBOpenError(EffectException):
|
|
def __init__(self, msg='', *args, **kwargs):
|
|
self.error_no = DB_OPEN_ERROR
|
|
self.msg = msg
|
|
EffectException.__init__(self, self.error_no, self.msg, *args, **kwargs)
|
|
|
|
|
|
class DBFullError(EffectException):
|
|
def __init__(self, msg='', *args, **kwargs):
|
|
self.error_no = DB_FULL_ERROR
|
|
self.msg = msg
|
|
EffectException.__init__(self, self.error_no, self.msg, *args, **kwargs)
|
|
|
|
|
|
class DBLongQueryError(EffectException):
|
|
def __init__(self, msg='', *args, **kwargs):
|
|
self.error_no = DB_LONG_QUERY_ERROR
|
|
self.msg = msg
|
|
EffectException.__init__(self, self.error_no, self.msg, *args, **kwargs)
|
|
|
|
|
|
class DBQueryError(EffectException):
|
|
def __init__(self, msg='', *args, **kwargs):
|
|
self.error_no = DB_QUERY_ERROR
|
|
self.msg = msg
|
|
EffectException.__init__(self, self.error_no, self.msg, *args, **kwargs)
|
|
|
|
|
|
class DBUnknownError(EffectException):
|
|
def __init__(self, msg='', *args, **kwargs):
|
|
self.error_no = DB_UNKNOWN_ERROR
|
|
self.msg = msg
|
|
EffectException.__init__(self, self.error_no, self.msg, *args, **kwargs)
|
|
|
|
|
|
class InternetError(EffectException):
|
|
def __init__(self, msg='', *args, **kwargs):
|
|
self.error_no = INTERNET_ERROR
|
|
self.msg = msg
|
|
EffectException.__init__(self, self.error_no, self.msg, *args, **kwargs)
|
|
|
|
|
|
class OutDatedCrawler(EffectException):
|
|
def __init__(self, msg='', *args, **kwargs):
|
|
self.error_no = OUT_DATED_CRAWLER
|
|
self.msg = msg
|
|
EffectException.__init__(self, self.error_no, self.msg, *args, **kwargs)
|
|
|
|
|
|
class DeletedUrlError(EffectException):
|
|
def __init__(self, msg='', *args, **kwargs):
|
|
self.error_no = DELETED_URL_ERROR
|
|
self.msg = msg
|
|
EffectException.__init__(self, self.error_no, self.msg, *args, **kwargs)
|
|
|
|
|
|
class BlockError(EffectException):
|
|
def __init__(self, msg='', *args, **kwargs):
|
|
self.error_no = BLOCK_ERROR
|
|
self.msg = msg
|
|
EffectException.__init__(self, self.error_no, self.msg, *args, **kwargs)
|
|
|
|
|
|
class TimeOutError(EffectException):
|
|
def __init__(self, msg='', *args, **kwargs):
|
|
self.error_no = TIMEOUT
|
|
self.msg = msg
|
|
EffectException.__init__(self, self.error_no, self.msg, *args, **kwargs)
|
|
|
|
|
|
class NoProgramError(EffectException):
|
|
def __init__(self, msg='', *args, **kwargs):
|
|
self.error_no = NO_PROGRAM
|
|
self.msg = msg
|
|
EffectException.__init__(self, self.error_no, self.msg, *args, **kwargs)
|
|
|
|
|
|
class UnknownError(EffectException):
|
|
def __init__(self, msg='', *args, **kwargs):
|
|
self.error_no = UNKNOWN_ERROR
|
|
self.msg = msg
|
|
EffectException.__init__(self, self.error_no, self.msg, *args, **kwargs)
|
|
|
|
|