How does gRPC handle errors?
Why Interviewers Ask This
This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex gRPC topics. It also reveals how well you can explain technical ideas to non-experts.
Answer
gRPC errors are represented by a status containing a StatusCode and an optional message. When an RPC fails, the client receives an error object that wraps these. In Go: st, ok := status.FromError(err); if ok { fmt.Println(st.Code(), st.Message()) }. Servers return errors using the status API: return nil, status.Errorf(codes.NotFound, "user %d not found", id). For richer error details, gRPC supports error details via the google.rpc.Status Protobuf message, which can carry structured error information (field violations, retry info, resource info). The google.rpc package provides standard error detail types: BadRequest with field violations for validation errors, RetryInfo for temporary failures, and ErrorInfo for domain-specific errors. Avoid using UNKNOWN — always use the most specific status code.
Common Mistake
Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong gRPC candidates.