mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-17 11:31:18 +00:00
🔇 Feature: 调整日志输出格式与等级 (#1233)
This commit is contained in:
@ -46,10 +46,14 @@ class ParserExit(NoneBotException):
|
||||
self.status = status
|
||||
self.message = message
|
||||
|
||||
def __repr__(self):
|
||||
return f"<ParserExit status={self.status} message={self.message}>"
|
||||
def __repr__(self) -> str:
|
||||
return (
|
||||
f"ParserExit(status={self.status}"
|
||||
+ (f", message={self.message!r}" if self.message else "")
|
||||
+ ")"
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
return self.__repr__()
|
||||
|
||||
|
||||
@ -68,10 +72,10 @@ class IgnoredException(ProcessException):
|
||||
def __init__(self, reason: Any):
|
||||
self.reason: Any = reason
|
||||
|
||||
def __repr__(self):
|
||||
return f"<IgnoredException, reason={self.reason}>"
|
||||
def __repr__(self) -> str:
|
||||
return f"IgnoredException(reason={self.reason!r})"
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
return self.__repr__()
|
||||
|
||||
|
||||
@ -99,11 +103,14 @@ class TypeMisMatch(SkippedException):
|
||||
self.param: ModelField = param
|
||||
self.value: Any = value
|
||||
|
||||
def __repr__(self):
|
||||
return f"<TypeMisMatch, param={self.param}, value={self.value}>"
|
||||
def __repr__(self) -> str:
|
||||
return (
|
||||
f"TypeMisMatch(param={self.param.name}, "
|
||||
f"type={self.param._type_display()}, value={self.value!r}>"
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
self.__repr__()
|
||||
def __str__(self) -> str:
|
||||
return self.__repr__()
|
||||
|
||||
|
||||
class MockApiException(ProcessException):
|
||||
@ -116,10 +123,10 @@ class MockApiException(ProcessException):
|
||||
def __init__(self, result: Any):
|
||||
self.result = result
|
||||
|
||||
def __repr__(self):
|
||||
return f"<ApiCancelledException, result={self.result}>"
|
||||
def __repr__(self) -> str:
|
||||
return f"MockApiException(result={self.result!r})"
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
return self.__repr__()
|
||||
|
||||
|
||||
@ -195,7 +202,8 @@ class AdapterException(NoneBotException):
|
||||
adapter_name: 标识 adapter
|
||||
"""
|
||||
|
||||
def __init__(self, adapter_name: str) -> None:
|
||||
def __init__(self, adapter_name: str, *args: object) -> None:
|
||||
super().__init__(*args)
|
||||
self.adapter_name: str = adapter_name
|
||||
|
||||
|
||||
@ -231,4 +239,11 @@ class WebSocketClosed(DriverException):
|
||||
self.reason = reason
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<WebSocketClosed code={self.code} reason={self.reason}>"
|
||||
return (
|
||||
f"WebSocketClosed(code={self.code}"
|
||||
+ (f", reason={self.reason!r}" if self.reason else "")
|
||||
+ ")"
|
||||
)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.__repr__()
|
||||
|
Reference in New Issue
Block a user