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

Support for custom status codes #515

Closed
dconnelly opened this issue Jun 6, 2015 · 3 comments
Closed

Support for custom status codes #515

dconnelly opened this issue Jun 6, 2015 · 3 comments

Comments

@dconnelly
Copy link
Contributor

io.grpc.Status seems to be restricted to the built-in status codes provided, although javadoc suggests that new status codes can be used as long as they are not conflicting. Adding a factory method such as "Status.forCode" should be possible although this would require that the status code type be changed from an enum to integer constant. This may be a small price to pay for the added flexibility.

@ejona86
Copy link
Member

ejona86 commented Jun 8, 2015

Status is for a canonical status used by all gRPC servers and will only rarely be added to. I think you saw the comment "If new codes are added over time they must choose a numerical value that does not collide with any previously used value." This comment is not referring to applications adding codes, but gRPC as a whole adding new codes. The current set of codes should be able to appropriately describe almost any application status in a generic way.

For custom status information, use Metadata.

@ejona86 ejona86 closed this as completed Jun 8, 2015
@dconnelly
Copy link
Contributor Author

I assume a custom ServerInterceptor is required to set Metadata on a response. For convenience, would it make sense to allow Metadata to be attached to Status{Runtime}Exception?

@ejona86
Copy link
Member

ejona86 commented Jun 8, 2015

We could have Status-specific metadata attached to the Status, but I think at least @louiscryan doesn't think that gains too much. However, soon we hope to have a Context API (#262) that would be available via ThreadLocal and could be used by a ServerInterceptor to propagate information to the application.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants