Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return customized error message directly #72

Open
Georgi87 opened this issue Sep 21, 2015 · 0 comments
Open

Return customized error message directly #72

Georgi87 opened this issue Sep 21, 2015 · 0 comments

Comments

@Georgi87
Copy link

I have a function, which may return an error state:

@jsonrpc_method('eth_sendRawTransaction')
def eth_sendRawTransaction(request, arg1):
    if arg1 == 1:
        return "This worked"
    else:
        raise Error("This is an error")

The response I would like to get back is the following:

{"error": {"message": "This is an error"}, "jsonrpc": "2.0", "id": 7}

Instead I get a nested error message:

{"error": 
{"executable": "/home/vagrant/.pyenv/versions/2.7.9/bin/python", 
"code": 0, 
"name": "Error", 
"message": "Error: This is an error", 
"data": null, 
"stack": "Traceback (most recent call last):\n  File \"/home/vagrant/.pyenv/versions/2.7.9/lib/python2.7/site-packages/jsonrpc/site.py\", line 162, in response_dict\n    R = apply_version[version](method, request, D['params'])\n  File \"/home/vagrant/.pyenv/versions/2.7.9/lib/python2.7/site-packages/jsonrpc/site.py\", line 125, in <lambda>\n    apply_version = {'2.0': lambda f, r, p: f(r, **encode_kw(p)) if type(p) is dict else f(r, *p),\n  File \"/home/vagrant/.pyenv/versions/2.7.9/lib/python2.7/site-packages/jsonrpc/__init__.py\", line 242, in exc_printer\n    six.reraise(*sys.exc_info())\n  File \"/home/vagrant/.pyenv/versions/2.7.9/lib/python2.7/site-packages/jsonrpc/__init__.py\", line 234, in exc_printer\n    return _func(*a, **kw)\n  File \"/vagrant/factserver/eth/views.py\", line 22, in eth_sendRawTransaction\n    raise Error(response[\"error\"])\nError\n"}, 
"jsonrpc": "2.0", 
"id": 7}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant