public sealed class Status : IMessage<Status>, IEquatable<Status>, IDeepCloneable<Status>, IBufferMessage, IMessage
The Status type defines a logical error model that is suitable for
different programming environments, including REST APIs and RPC APIs. It is
used by gRPC. Each Status message contains
three pieces of data: error code, error message, and error details.
You can find out more about this error model and how to work with it in the
API Design Guide.
A developer-facing error message, which should be in English. Any
user-facing error message should be localized and sent in the
[google.rpc.Status.details][google.rpc.Status.details] field, or localized
by the client.
Iterate over the messages in the Details that are messages
in the
standard set of error types defined in the richer error model. Any other messages found in
the Details are ignored and not returned.
foreach (var msg in status.UnpackDetailMessages())
{
switch (msg)
{
case ErrorInfo errorInfo:
// Handle errorInfo ...
break;
// Other cases ...
}
}
Iterate over the messages in the Details that are messages
in the given TypeRegistry. Any other messages found in the Details are ignored
and not returned. This allows iterating over custom messages if you are not using the
standard set of error types defined in the rich error model.
TypeRegistry myTypes = TypeRegistry.FromMessages(FooMessage.Descriptor, BarMessage.Descriptor);
foreach (var msg in status.UnpackDetailMessages(myTypes))
{
switch (msg)
{
case FooMessage foo:
// Handle foo ...
break;
// Other cases ...
}
}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-12 UTC."],[[["The `Status` type is a logical error model used in various programming environments, including REST and RPC APIs, and is notably used by gRPC."],["A `Status` message contains three key components: an error code, an error message, and error details, all of which aid in defining the nature of an error."],["The `Status` class implements interfaces like `IMessage`, `IEquatable`, `IDeepCloneable`, and `IBufferMessage`, providing capabilities for message handling, equality checks, deep cloning, and buffer operations."],["Key fields within the `Status` class include `CodeFieldNumber`, `DetailsFieldNumber`, and `MessageFieldNumber`, each representing the error code, error details, and error message components, respectively."],["The `Status` class provides methods for detailed error analysis, such as `GetDetail\u003cT\u003e()` for retrieving specific error details and `UnpackDetailMessages()` for iterating through error messages."]]],[]]