gRPC status codes

gRPC status codes are standardized codes that describe the outcome of an RPC independently of its human-readable error message. In this course, domain errors such as ErrNotFound and ErrConflict are translated into appropriate gRPC codes so clients can handle failures consistently.

Minimal example

go
if errors.Is(err, ErrNotFound) {
    return status.Error(
        codes.NotFound,
        "order not found",
    )
}

Learn this concept

Lesson 7.12 · Protobuf contracts in Go

Used in exercises

Exercise 7.13 · gRPC order service Exercise 7.17 · gRPC resilience interceptors
Prerequisite conceptsgRPC