1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Possibly working bot

This commit is contained in:
Steffo 2019-10-15 13:01:02 +02:00
parent 04e5204819
commit 1750522321
2 changed files with 13 additions and 14 deletions

View file

@ -64,7 +64,7 @@ class GenericBot:
async def net_request(ci, request: rh.Request, destination: str) -> dict:
if self.network is None:
raise InvalidConfigError("Royalnet is not enabled on this bot")
raise Exception("Royalnet is not enabled on this bot")
response_dict: dict = await self.network.request(request.to_dict(), destination)
if "type" not in response_dict:
raise RoyalnetResponseError("Response is missing a type")
@ -117,13 +117,13 @@ class GenericBot:
except Exception as e:
sentry_sdk.capture_exception(e)
log.debug(f"Exception {e} in {network_handler}")
return rh.ResponseError("exception_in_handler",
f"An exception was raised in {network_handler} for {request.handler}. Check "
f"extra_info for details.",
extra_info={
"type": e.__class__.__name__,
"str": str(e)
}).to_dict()
return rh.ResponseFailure("exception_in_handler",
f"An exception was raised in {network_handler} for {request.handler}. Check "
f"extra_info for details.",
extra_info={
"type": e.__class__.__name__,
"str": str(e)
}).to_dict()
def _init_database(self):
"""Create an :py:class:`royalnet.database.Alchemy` with the tables required by the commands. Then,

View file

@ -1,14 +1,13 @@
import typing
if typing.TYPE_CHECKING:
from .network import ResponseError
import royalherald as rh
class RoyalnetRequestError(Exception):
"""An error was raised while handling the Royalnet request.
This exception contains the :py:class:`royalnet.network.ResponseError` that was returned by the other Link."""
def __init__(self, error: "ResponseError"):
self.error: "ResponseError" = error
This exception contains the :py:class:`royalherald.ResponseFailure` that was returned by the other Link."""
def __init__(self, error: rh.ResponseFailure):
self.error: rh.ResponseFailure = error
@property
def args(self):
@ -16,4 +15,4 @@ class RoyalnetRequestError(Exception):
class RoyalnetResponseError(Exception):
"""The :py:class:`royalnet.network.Response` that was received is invalid."""
"""The :py:class:`royalherald.Response` that was received is invalid."""