edjCase / JsonRpc

Json Rpc Router for Asp.Net Core
MIT License
141 stars 42 forks source link

Application defined errors #29

Closed hey-red closed 8 years ago

hey-red commented 8 years ago

From JSON RPC specification How to create app defined error response? Throwing RpcException in user input validation it's bad way. Maybe pass rpc obj through DI and use method like SetErrorResponse in RPC controller?

Gekctek commented 8 years ago

It looks like from the specification (as far as i can tell) that the errors it returns is just about rpc processing except for the -32000 to -32099 range of error codes which can be customized per implementation. I have no way right now to have those be set, but it is a thing I have been thinking about and working on. I plan to have a MVC like way of returning the errors such as returing Ok(responseObject) or BadRequest("ErrorMessage") but havent quite figured it out. The only way to do it right now is to return a wrapper object that holds a result/error code for your request. This is the next thing that I will be implementing.

hey-red commented 8 years ago

All codes >-32000 or <-32768 application defined errors.

Gekctek commented 8 years ago

From what I get the range -32000 to -32099. Is reserved for the application while the -32100 to -32768 are reserved for future use for the routing. So a user should only be doing a custom error that is between -32000 to -32099. Otherwise the router should handle it.

Gekctek commented 8 years ago

Look at the updated README.md to see the new IRpcMethodResult return type. Also this is pushed to nuget but as a prerelease

hey-red commented 8 years ago

https://github.com/zendframework/zendframework/issues/2456#issuecomment-15134060

Gekctek commented 8 years ago

Ill change it to allow all error codes

Gekctek commented 8 years ago

Updated Nuget package