You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
416B

  1. # -*- coding: utf-8 -*-
  2. from loguru import logger
  3. """
  4. 自定义异常
  5. """
  6. class ServiceException(Exception): # 继承异常类
  7. def __init__(self, code, msg, desc=None):
  8. self.code = code
  9. if desc is None:
  10. self.msg = msg
  11. else:
  12. self.msg = msg % desc
  13. def __str__(self):
  14. logger.error("异常编码:{}, 异常描述:{}", self.code, self.msg)