execptions.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. class YbwCrawlError(Exception):
  2. def __init__(self, *args, **kwargs):
  3. if 'code' not in kwargs and 'reason' not in kwargs:
  4. kwargs['code'] = 10000
  5. kwargs['reason'] = '元博网采集未知错误,请手动处理'
  6. for key, val in kwargs.items():
  7. setattr(self, key, val)
  8. super(YbwCrawlError, self).__init__(*args, kwargs)
  9. class AccountError(YbwCrawlError):
  10. def __init__(self, reason='账号异常', code=10001, **kwargs):
  11. super(AccountError, self).__init__(code=code, reason=reason, **kwargs)
  12. class CheckError(YbwCrawlError):
  13. def __init__(self, reason='数据检查异常', code=10002, **kwargs):
  14. super(CheckError, self).__init__(code=code, reason=reason, **kwargs)
  15. class CrawlError(YbwCrawlError):
  16. def __init__(self, reason='数据采集异常', code=10003, **kwargs):
  17. super(CrawlError, self).__init__(code=code, reason=reason, **kwargs)
  18. class AttachmentError(YbwCrawlError):
  19. def __init__(self, reason='附件异常', code=10004, **kwargs):
  20. super(AttachmentError, self).__init__(code=code, reason=reason, **kwargs)