Spring / Spring gRPC Interview Questions
How should errors be communicated back to the client in gRPC, and how does this differ from throwing a plain exception?
Errors should be surfaced explicitly through gRPC's Status/StatusRuntimeException mechanism, e.g. Status.INVALID_ARGUMENT.withDescription("customerId is required").asRuntimeException(), optionally enriched with structured google.rpc.Status details for machine-readable error payloads.
If an unchecked exception is instead allowed to propagate out of a service method uncaught, grpc-java will typically translate it into an opaque UNKNOWN status on the client side, stripping away the specific error semantics (was it a bad request? not found? a downstream timeout?) that a well-chosen Status code would have conveyed. Deliberate status mapping is therefore part of designing the service contract, not an afterthought.
More Related questions...