question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

send exception message instead of "Server error"

See original GitHub issue

When RPC methods raises an exception there is always the same reply returned:

INFO jsonrpcclient.client.response: {"jsonrpc": "2.0", "error": {"code": -32000, "message": "Server error"}, "id": 2}

It would be great if ‘message’ could contain str(exception) that was thrown by called method.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
seidlmiccommented, Jan 30, 2019

I would like to implement application defined errors with specific code, message and data (https://www.jsonrpc.org/specification#response_object). So something like {"jsonrpc": "2.0", "error": {"code": -32800, "message": "Invalid input geometry", "data": {"index": 33, "coordinates": [1135.124, -25689]}}, "id": "1"} I would like to raise application defined exception in rpc method that I would handle in the way shown above. I am working with geo data that are not always perfect.

2reactions
okke-formsmacommented, Feb 12, 2019

I have the same issue as @seidlmic.

One approach would be to raise a ExceptionResponse from inside the method. This way, all ‘specially handled’ exceptions will get the proper response, and ‘normal’ exceptions get the generic jsonrpc exception handling.

To make this happen, we only have to adjust the handle_exceptions call to catch ExceptionResponses and rethrow them.

Also could you reopen this issue? It took me a while to find this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get specific error instead of Internal Server Error?
Let's say I have my controller and I implicitly throw an exception. @RestController public class HelloWorldController { @GetMapping("/hello- ...
Read more >
Best Practices for exceptions - .NET - Microsoft Learn
Learn best practices for exceptions, such as using try/catch/finally, handling common conditions without exceptions, and using predefined .
Read more >
send exception message instead of "Server error" #71 - GitHub
Let's say, the client tries to read a file. This can fail for various reasons (file does not exist, client has no permission,...
Read more >
Throwing an exception always gives 500 Internal Server Error
Suppose I want to raise an Exception in, say, an OnPost in my DTO, because the data supplied by the client was invalid....
Read more >
Custom Error Messages in Spring REST API - amitph
Learn a different ways of handling most common Spring exceptions and returning detailed custom error messages from a Spring REST API.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found