How to use the jsonrpcserver.exceptions.JsonRpcServerError function in jsonrpcserver

To help you get started, we’ve selected a few jsonrpcserver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bcb / jsonrpcserver / tests / test_exceptions.py View on Github external
def test_raise(self):
        with self.assertRaises(JsonRpcServerError):
            raise JsonRpcServerError()
github bcb / jsonrpcserver / jsonrpcserver / exceptions.py View on Github external
class JsonRpcServerError(Exception):
    """
    Base class for the other exceptions.

    :param data: Extra info (optional).
    """

    message = None

    def __init__(self, data=None):
        super(JsonRpcServerError, self).__init__(self.message)
        # Holds extra information related to the error.
        self.data = data


class ParseError(JsonRpcServerError):
    """Raised when the request is not a valid JSON object."""

    code = -32700
    message = "Parse error"
    http_status = status.HTTP_BAD_REQUEST


class InvalidRequest(JsonRpcServerError):
    """
    Raised when the request is not a valid JSON-RPC object.

    :param data: Extra information about the error that occurred (optional).
    """

    code = -32600
    message = "Invalid Request"
github bcb / jsonrpcserver / jsonrpcserver / blueprint.py View on Github external
@bp.app_errorhandler(exceptions.JsonRpcServerError)
def custom_exception_error_handler(exc):
    """Catch any JsonRpcServerError exception, and convert it to
    jsonrpc format."""

    return flask_error_response(exc.http_status_code, str(exc))
github bcb / jsonrpcserver / jsonrpcserver / exceptions.py View on Github external
def __init__(self, data=None):
        super(JsonRpcServerError, self).__init__(self.message)
        # Holds extra information related to the error.
        self.data = data
github bcb / jsonrpcserver / jsonrpcserver / exceptions.py View on Github external
http_status = status.HTTP_NOT_FOUND


class InvalidParams(JsonRpcServerError):
    """
    Raised when invalid arguments are passed to a method.

    :param data: Extra information about the error that occurred (optional).
    """

    code = -32602
    message = "Invalid params"
    http_status = status.HTTP_BAD_REQUEST


class ServerError(JsonRpcServerError):
    """
    Raised when there's an application-specific error on the server side.

    :param data: Extra information about the error that occurred (optional).
    """

    code = -32000
    message = "Server error"
    http_status = status.HTTP_INTERNAL_ERROR
github icon-project / t-bears / tbears / server / jsonrpc_server.py View on Github external
http_status=status.HTTP_BAD_REQUEST
        )


def response_to_json_query(response):
    if check_error_response(response):
        response: dict = response['error']
        raise GenericJsonRpcServerError(
            code=-int(response['code']),
            message=response['message'],
            http_status=status.HTTP_BAD_REQUEST
        )
    return response


class GenericJsonRpcServerError(JsonRpcServerError):
    """Raised when the request is not a valid JSON-RPC object.
    User can change code and message properly

    :param data: Extra information about the error that occurred (optional).
    """

    def __init__(self, code: int, message: str, http_status: int, data=None):
        """

        :param code: json-rpc error code
        :param message: json-rpc error message
        :param http_status: http status code
        :param data: json-rpc error data (optional)
        """
        super().__init__(data)
github bcb / jsonrpcserver / jsonrpcserver / exceptions.py View on Github external
def __init__(self, data=None):
        super(JsonRpcServerError, self).__init__(self.message)
        # Holds extra information related to the error.
        self.data = data


class ParseError(JsonRpcServerError):
    """Raised when the request is not a valid JSON object."""

    code = -32700
    message = "Parse error"
    http_status = status.HTTP_BAD_REQUEST


class InvalidRequest(JsonRpcServerError):
    """
    Raised when the request is not a valid JSON-RPC object.

    :param data: Extra information about the error that occurred (optional).
    """

    code = -32600
    message = "Invalid Request"
    http_status = status.HTTP_BAD_REQUEST


class MethodNotFound(JsonRpcServerError):
    """
    Raised when the method does not exist/is not available.

    :param data: Extra information about the error that occurred (optional).
github bcb / jsonrpcserver / jsonrpcserver / exceptions.py View on Github external
http_status = status.HTTP_BAD_REQUEST


class MethodNotFound(JsonRpcServerError):
    """
    Raised when the method does not exist/is not available.

    :param data: Extra information about the error that occurred (optional).
    """

    code = -32601
    message = "Method not found"
    http_status = status.HTTP_NOT_FOUND


class InvalidParams(JsonRpcServerError):
    """
    Raised when invalid arguments are passed to a method.

    :param data: Extra information about the error that occurred (optional).
    """

    code = -32602
    message = "Invalid params"
    http_status = status.HTTP_BAD_REQUEST


class ServerError(JsonRpcServerError):
    """
    Raised when there's an application-specific error on the server side.

    :param data: Extra information about the error that occurred (optional).
github bcb / jsonrpcserver / jsonrpcserver / exceptions.py View on Github external
http_status = status.HTTP_BAD_REQUEST


class InvalidRequest(JsonRpcServerError):
    """
    Raised when the request is not a valid JSON-RPC object.

    :param data: Extra information about the error that occurred (optional).
    """

    code = -32600
    message = "Invalid Request"
    http_status = status.HTTP_BAD_REQUEST


class MethodNotFound(JsonRpcServerError):
    """
    Raised when the method does not exist/is not available.

    :param data: Extra information about the error that occurred (optional).
    """

    code = -32601
    message = "Method not found"
    http_status = status.HTTP_NOT_FOUND


class InvalidParams(JsonRpcServerError):
    """
    Raised when invalid arguments are passed to a method.

    :param data: Extra information about the error that occurred (optional).
github icon-project / loopchain / loopchain / jsonrpc / exception.py View on Github external
# limitations under the License.

from jsonrpcserver.exceptions import JsonRpcServerError


class JsonError:
    PARSE_ERROR = -32700
    INVALID_REQUEST = -32600
    METHOD_NOT_FOUND = -32601
    INVALID_PARAMS = -32602
    INTERNAL_ERROR = -32603
    SERVER_ERROR = -32000
    SCORE_ERROR = -32100


class GenericJsonRpcServerError(JsonRpcServerError):
    """Raised when the request is not a valid JSON-RPC object.
    User can change code and message properly

    :param data: Extra information about the error that occurred (optional).
    """

    def __init__(self, code: int, message: str, http_status: int, data=None):
        """

        :param code: json-rpc error code
        :param message: json-rpc error message
        :param http_status: http status code
        :param data: json-rpc error data (optional)
        """
        super().__init__(data)