public static final class Status.Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder> implements StatusOrBuilder
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](https://github.com/grpc). The error model is designed to be:
- Simple to use and understand for most users
- Flexible enough to meet unexpected needs
# Overview
The `Status` message contains three pieces of data: error code, error message,
and error details. The error code should be an enum value of
[google.rpc.Code][google.rpc.Code], but it may accept additional error codes if needed. The
error message should be a developer-facing English message that helps
developers *understand* and *resolve* the error. If a localized user-facing
error message is needed, put the localized message in the error details or
localize it in the client. The optional error details may contain arbitrary
information about the error. There is a predefined set of error detail types
in the package `google.rpc` that can be used for common error conditions.
# Language mapping
The `Status` message is the logical representation of the error model, but it
is not necessarily the actual wire format. When the `Status` message is
exposed in different client libraries and different wire protocols, it can be
mapped differently. For example, it will likely be mapped to some exceptions
in Java, but more likely mapped to some error codes in C.
# Other uses
The error model and the `Status` message can be used in a variety of
environments, either with or without APIs, to provide a
consistent developer experience across different environments.
Example uses of this error model include:
- Partial errors. If a service needs to return partial errors to the client,
it may embed the `Status` in the normal response to indicate the partial
errors.
- Workflow errors. A typical workflow has multiple steps. Each step may
have a `Status` message for error reporting.
- Batch operations. If a client uses batch request and batch response, the
`Status` message should be used directly inside batch response, one for
each error sub-response.
- Asynchronous operations. If an API call embeds asynchronous operation
results in its response, the status of those operations should be
represented directly using the `Status` message.
- Logging. If some API errors are stored in logs, the message `Status` could
be used directly after any stripping needed for security/privacy reasons.
Protobuf type google.rpc.Status| Modifier and Type | Method and Description |
|---|---|
Status.Builder |
addAllDetails(java.lang.Iterable<? extends com.google.protobuf.Any> values)
A list of messages that carry the error details.
|
Status.Builder |
addDetails(com.google.protobuf.Any.Builder builderForValue)
A list of messages that carry the error details.
|
Status.Builder |
addDetails(com.google.protobuf.Any value)
A list of messages that carry the error details.
|
Status.Builder |
addDetails(int index,
com.google.protobuf.Any.Builder builderForValue)
A list of messages that carry the error details.
|
Status.Builder |
addDetails(int index,
com.google.protobuf.Any value)
A list of messages that carry the error details.
|
com.google.protobuf.Any.Builder |
addDetailsBuilder()
A list of messages that carry the error details.
|
com.google.protobuf.Any.Builder |
addDetailsBuilder(int index)
A list of messages that carry the error details.
|
Status.Builder |
addRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field,
java.lang.Object value) |
Status |
build() |
Status |
buildPartial() |
Status.Builder |
clear() |
Status.Builder |
clearCode()
The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
|
Status.Builder |
clearDetails()
A list of messages that carry the error details.
|
Status.Builder |
clearField(com.google.protobuf.Descriptors.FieldDescriptor field) |
Status.Builder |
clearMessage()
A developer-facing error message, which should be in English.
|
Status.Builder |
clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) |
Status.Builder |
clone() |
int |
getCode()
The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
|
Status |
getDefaultInstanceForType() |
static com.google.protobuf.Descriptors.Descriptor |
getDescriptor() |
com.google.protobuf.Descriptors.Descriptor |
getDescriptorForType() |
com.google.protobuf.Any |
getDetails(int index)
A list of messages that carry the error details.
|
com.google.protobuf.Any.Builder |
getDetailsBuilder(int index)
A list of messages that carry the error details.
|
java.util.List<com.google.protobuf.Any.Builder> |
getDetailsBuilderList()
A list of messages that carry the error details.
|
int |
getDetailsCount()
A list of messages that carry the error details.
|
java.util.List<com.google.protobuf.Any> |
getDetailsList()
A list of messages that carry the error details.
|
com.google.protobuf.AnyOrBuilder |
getDetailsOrBuilder(int index)
A list of messages that carry the error details.
|
java.util.List<? extends com.google.protobuf.AnyOrBuilder> |
getDetailsOrBuilderList()
A list of messages that carry the error details.
|
java.lang.String |
getMessage()
A developer-facing error message, which should be in English.
|
com.google.protobuf.ByteString |
getMessageBytes()
A developer-facing error message, which should be in English.
|
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable |
internalGetFieldAccessorTable() |
boolean |
isInitialized() |
Status.Builder |
mergeFrom(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
Status.Builder |
mergeFrom(com.google.protobuf.Message other) |
Status.Builder |
mergeFrom(Status other) |
Status.Builder |
mergeUnknownFields(com.google.protobuf.UnknownFieldSet unknownFields) |
Status.Builder |
removeDetails(int index)
A list of messages that carry the error details.
|
Status.Builder |
setCode(int value)
The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
|
Status.Builder |
setDetails(int index,
com.google.protobuf.Any.Builder builderForValue)
A list of messages that carry the error details.
|
Status.Builder |
setDetails(int index,
com.google.protobuf.Any value)
A list of messages that carry the error details.
|
Status.Builder |
setField(com.google.protobuf.Descriptors.FieldDescriptor field,
java.lang.Object value) |
Status.Builder |
setMessage(java.lang.String value)
A developer-facing error message, which should be in English.
|
Status.Builder |
setMessageBytes(com.google.protobuf.ByteString value)
A developer-facing error message, which should be in English.
|
Status.Builder |
setRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field,
int index,
java.lang.Object value) |
Status.Builder |
setUnknownFields(com.google.protobuf.UnknownFieldSet unknownFields) |
getAllFields, getField, getFieldBuilder, getOneofFieldDescriptor, getParentForChildren, getRepeatedField, getRepeatedFieldBuilder, getRepeatedFieldCount, getUnknownFields, hasField, hasOneof, internalGetMapField, internalGetMutableMapField, isClean, markClean, newBuilderForField, onBuilt, onChanged, setUnknownFieldsProto3findInitializationErrors, getInitializationErrorString, internalMergeFrom, mergeDelimitedFrom, mergeDelimitedFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, newUninitializedMessageException, toStringaddAll, addAll, mergeFrom, newUninitializedMessageExceptionequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
internalGetFieldAccessorTable in class com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public Status.Builder clear()
clear in interface com.google.protobuf.Message.Builderclear in interface com.google.protobuf.MessageLite.Builderclear in class com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public com.google.protobuf.Descriptors.Descriptor getDescriptorForType()
getDescriptorForType in interface com.google.protobuf.Message.BuildergetDescriptorForType in interface com.google.protobuf.MessageOrBuildergetDescriptorForType in class com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public Status getDefaultInstanceForType()
getDefaultInstanceForType in interface com.google.protobuf.MessageLiteOrBuildergetDefaultInstanceForType in interface com.google.protobuf.MessageOrBuilderpublic Status build()
build in interface com.google.protobuf.Message.Builderbuild in interface com.google.protobuf.MessageLite.Builderpublic Status buildPartial()
buildPartial in interface com.google.protobuf.Message.BuilderbuildPartial in interface com.google.protobuf.MessageLite.Builderpublic Status.Builder clone()
clone in interface com.google.protobuf.Message.Builderclone in interface com.google.protobuf.MessageLite.Builderclone in class com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public Status.Builder setField(com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value)
setField in interface com.google.protobuf.Message.BuildersetField in class com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public Status.Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field)
clearField in interface com.google.protobuf.Message.BuilderclearField in class com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public Status.Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof)
clearOneof in interface com.google.protobuf.Message.BuilderclearOneof in class com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public Status.Builder setRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value)
setRepeatedField in interface com.google.protobuf.Message.BuildersetRepeatedField in class com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public Status.Builder addRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value)
addRepeatedField in interface com.google.protobuf.Message.BuilderaddRepeatedField in class com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public Status.Builder mergeFrom(com.google.protobuf.Message other)
mergeFrom in interface com.google.protobuf.Message.BuildermergeFrom in class com.google.protobuf.AbstractMessage.Builder<Status.Builder>public Status.Builder mergeFrom(Status other)
public final boolean isInitialized()
isInitialized in interface com.google.protobuf.MessageLiteOrBuilderisInitialized in class com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public Status.Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException
mergeFrom in interface com.google.protobuf.Message.BuildermergeFrom in interface com.google.protobuf.MessageLite.BuildermergeFrom in class com.google.protobuf.AbstractMessage.Builder<Status.Builder>java.io.IOExceptionpublic int getCode()
The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
int32 code = 1;getCode in interface StatusOrBuilderpublic Status.Builder setCode(int value)
The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
int32 code = 1;public Status.Builder clearCode()
The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
int32 code = 1;public java.lang.String getMessage()
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.
string message = 2;getMessage in interface StatusOrBuilderpublic com.google.protobuf.ByteString getMessageBytes()
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.
string message = 2;getMessageBytes in interface StatusOrBuilderpublic Status.Builder setMessage(java.lang.String value)
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.
string message = 2;public Status.Builder clearMessage()
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.
string message = 2;public Status.Builder setMessageBytes(com.google.protobuf.ByteString value)
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.
string message = 2;public java.util.List<com.google.protobuf.Any> getDetailsList()
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;getDetailsList in interface StatusOrBuilderpublic int getDetailsCount()
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;getDetailsCount in interface StatusOrBuilderpublic com.google.protobuf.Any getDetails(int index)
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;getDetails in interface StatusOrBuilderpublic Status.Builder setDetails(int index, com.google.protobuf.Any value)
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public Status.Builder setDetails(int index, com.google.protobuf.Any.Builder builderForValue)
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public Status.Builder addDetails(com.google.protobuf.Any value)
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public Status.Builder addDetails(int index, com.google.protobuf.Any value)
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public Status.Builder addDetails(com.google.protobuf.Any.Builder builderForValue)
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public Status.Builder addDetails(int index, com.google.protobuf.Any.Builder builderForValue)
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public Status.Builder addAllDetails(java.lang.Iterable<? extends com.google.protobuf.Any> values)
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public Status.Builder clearDetails()
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public Status.Builder removeDetails(int index)
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public com.google.protobuf.Any.Builder getDetailsBuilder(int index)
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public com.google.protobuf.AnyOrBuilder getDetailsOrBuilder(int index)
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;getDetailsOrBuilder in interface StatusOrBuilderpublic java.util.List<? extends com.google.protobuf.AnyOrBuilder> getDetailsOrBuilderList()
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;getDetailsOrBuilderList in interface StatusOrBuilderpublic com.google.protobuf.Any.Builder addDetailsBuilder()
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public com.google.protobuf.Any.Builder addDetailsBuilder(int index)
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public java.util.List<com.google.protobuf.Any.Builder> getDetailsBuilderList()
A list of messages that carry the error details. There is a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public final Status.Builder setUnknownFields(com.google.protobuf.UnknownFieldSet unknownFields)
setUnknownFields in interface com.google.protobuf.Message.BuildersetUnknownFields in class com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public final Status.Builder mergeUnknownFields(com.google.protobuf.UnknownFieldSet unknownFields)
mergeUnknownFields in interface com.google.protobuf.Message.BuildermergeUnknownFields in class com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>