send exception message instead of "Server error"
See original GitHub issueWhen 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:
- Created 5 years ago
- Comments:19 (10 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.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.