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:
parent
04e5204819
commit
1750522321
2 changed files with 13 additions and 14 deletions
|
@ -64,7 +64,7 @@ class GenericBot:
|
||||||
|
|
||||||
async def net_request(ci, request: rh.Request, destination: str) -> dict:
|
async def net_request(ci, request: rh.Request, destination: str) -> dict:
|
||||||
if self.network is None:
|
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)
|
response_dict: dict = await self.network.request(request.to_dict(), destination)
|
||||||
if "type" not in response_dict:
|
if "type" not in response_dict:
|
||||||
raise RoyalnetResponseError("Response is missing a type")
|
raise RoyalnetResponseError("Response is missing a type")
|
||||||
|
@ -117,13 +117,13 @@ class GenericBot:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sentry_sdk.capture_exception(e)
|
sentry_sdk.capture_exception(e)
|
||||||
log.debug(f"Exception {e} in {network_handler}")
|
log.debug(f"Exception {e} in {network_handler}")
|
||||||
return rh.ResponseError("exception_in_handler",
|
return rh.ResponseFailure("exception_in_handler",
|
||||||
f"An exception was raised in {network_handler} for {request.handler}. Check "
|
f"An exception was raised in {network_handler} for {request.handler}. Check "
|
||||||
f"extra_info for details.",
|
f"extra_info for details.",
|
||||||
extra_info={
|
extra_info={
|
||||||
"type": e.__class__.__name__,
|
"type": e.__class__.__name__,
|
||||||
"str": str(e)
|
"str": str(e)
|
||||||
}).to_dict()
|
}).to_dict()
|
||||||
|
|
||||||
def _init_database(self):
|
def _init_database(self):
|
||||||
"""Create an :py:class:`royalnet.database.Alchemy` with the tables required by the commands. Then,
|
"""Create an :py:class:`royalnet.database.Alchemy` with the tables required by the commands. Then,
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import typing
|
import typing
|
||||||
if typing.TYPE_CHECKING:
|
import royalherald as rh
|
||||||
from .network import ResponseError
|
|
||||||
|
|
||||||
|
|
||||||
class RoyalnetRequestError(Exception):
|
class RoyalnetRequestError(Exception):
|
||||||
"""An error was raised while handling the Royalnet request.
|
"""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."""
|
This exception contains the :py:class:`royalherald.ResponseFailure` that was returned by the other Link."""
|
||||||
def __init__(self, error: "ResponseError"):
|
def __init__(self, error: rh.ResponseFailure):
|
||||||
self.error: "ResponseError" = error
|
self.error: rh.ResponseFailure = error
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def args(self):
|
def args(self):
|
||||||
|
@ -16,4 +15,4 @@ class RoyalnetRequestError(Exception):
|
||||||
|
|
||||||
|
|
||||||
class RoyalnetResponseError(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."""
|
||||||
|
|
Loading…
Reference in a new issue