execptions.py 1.2 KB

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