diff --git a/galaxy/api/errors.py b/galaxy/api/errors.py index 1099a16..3e1921d 100644 --- a/galaxy/api/errors.py +++ b/galaxy/api/errors.py @@ -1,8 +1,6 @@ -from galaxy.api.jsonrpc import ApplicationError +from galaxy.api.jsonrpc import ApplicationError, UnknownError -class UnknownError(ApplicationError): - def __init__(self, data=None): - super().__init__(0, "Unknown error", data) +UnknownError = UnknownError class AuthenticationRequired(ApplicationError): def __init__(self, data=None): diff --git a/galaxy/api/jsonrpc.py b/galaxy/api/jsonrpc.py index a00f72d..033c04c 100644 --- a/galaxy/api/jsonrpc.py +++ b/galaxy/api/jsonrpc.py @@ -41,6 +41,10 @@ class ApplicationError(JsonRpcError): raise ValueError("The error code in reserved range") super().__init__(code, message, data) +class UnknownError(ApplicationError): + def __init__(self, data=None): + super().__init__(0, "Unknown error", data) + Request = namedtuple("Request", ["method", "params", "id"], defaults=[{}, None]) Method = namedtuple("Method", ["callback", "internal", "sensitive_params"]) @@ -171,8 +175,9 @@ class Server(): self._send_error(request.id, MethodNotFound()) except JsonRpcError as error: self._send_error(request.id, error) - except Exception: #pylint: disable=broad-except + except Exception as e: #pylint: disable=broad-except logging.exception("Unexpected exception raised in plugin handler") + self._send_error(request.id, UnknownError(str(e))) asyncio.create_task(handle())