nonebot2/nonebot/exception.py

56 lines
1.1 KiB
Python
Raw Normal View History

2020-06-30 10:13:58 +08:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
2020-08-13 15:23:04 +08:00
from nonebot.typing import Optional
2020-06-30 10:13:58 +08:00
2020-07-25 12:28:30 +08:00
class IgnoredException(Exception):
"""
Raised by event_preprocessor indicating that
the bot should ignore the event
"""
def __init__(self, reason):
"""
:param reason: reason to ignore the event
"""
self.reason = reason
2020-05-05 16:11:05 +08:00
class PausedException(Exception):
"""Block a message from further handling and try to receive a new message"""
2020-05-02 20:03:36 +08:00
pass
class RejectedException(Exception):
"""Reject a message and return current handler back"""
pass
2020-05-05 16:11:05 +08:00
class FinishedException(Exception):
"""Finish handling a message"""
pass
2020-08-01 22:03:40 +08:00
class ApiNotAvailable(Exception):
"""Api is not available"""
pass
2020-08-13 15:23:04 +08:00
class NetworkError(Exception):
"""There is something error with the network"""
pass
class ActionFailed(Exception):
"""The action call returned a failed response"""
def __init__(self, retcode: Optional[int]):
self.retcode = retcode
def __repr__(self):
return f"<ActionFailed, retcode={self.retcode}>"
def __str__(self):
return self.__repr__()