Skip to content

Commit

Permalink
🐛 修复异常在 traceback 中无法正常显示信息 (#1521)
Browse files Browse the repository at this point in the history
he0119 authored Dec 31, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent f0bebb6 commit 9b3e670
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions nonebot/exception.py
Original file line number Diff line number Diff line change
@@ -37,6 +37,9 @@
class NoneBotException(Exception):
"""所有 NoneBot 发生的异常基类。"""

def __str__(self) -> str:
return self.__repr__()


# Rule Exception
class ParserExit(NoneBotException):
@@ -53,9 +56,6 @@ def __repr__(self) -> str:
+ ")"
)

def __str__(self) -> str:
return self.__repr__()


# Processor Exception
class ProcessException(NoneBotException):
@@ -75,9 +75,6 @@ def __init__(self, reason: Any):
def __repr__(self) -> str:
return f"IgnoredException(reason={self.reason!r})"

def __str__(self) -> str:
return self.__repr__()


class SkippedException(ProcessException):
"""指示 NoneBot 立即结束当前 `Dependent` 的运行。
@@ -109,9 +106,6 @@ def __repr__(self) -> str:
f"type={self.param._type_display()}, value={self.value!r}>"
)

def __str__(self) -> str:
return self.__repr__()


class MockApiException(ProcessException):
"""指示 NoneBot 阻止本次 API 调用或修改本次调用返回值,并返回自定义内容。可由 api hook 抛出。
@@ -126,9 +120,6 @@ def __init__(self, result: Any):
def __repr__(self) -> str:
return f"MockApiException(result={self.result!r})"

def __str__(self) -> str:
return self.__repr__()


class StopPropagation(ProcessException):
"""指示 NoneBot 终止事件向下层传播。
@@ -244,6 +235,3 @@ def __repr__(self) -> str:
+ (f", reason={self.reason!r}" if self.reason else "")
+ ")"
)

def __str__(self) -> str:
return self.__repr__()

0 comments on commit 9b3e670

Please sign in to comment.