execptions.py 572 B

123456789101112131415
  1. class PySpiderError(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(PySpiderError, self).__init__(*args, kwargs)
  9. class AttachmentNullError(PySpiderError):
  10. def __init__(self, code: int = 10004, reason: str = '附件下载异常'):
  11. super(AttachmentNullError, self).__init__(code=code, reason=reason)