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

18 lines
546 B
Python

from werkzeug.exceptions import HTTPException
class BizException(HTTPException):
def __init__(self, message: str = "操作失败", code: int = 500, data=None):
self.message = message
self.code = code
self.data = data
def __str__(self):
return f"{self.message} (code: {self.code}) (data: {self.data})"
def __repr__(self):
return f"{self.message} (code: {self.code}) (data: {self.data})"
def __dict__(self):
return {"message": self.message, "code": self.code, "data": self.data}