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` which 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 purpose.
- 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| 限定符和类型 | 方法和说明 |
|---|---|
Status.Builder |
addAllDetails(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 |
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 |
clearMessage()
A developer-facing error message, which should be in English.
|
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.
|
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.
|
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.
|
List<? extends com.google.protobuf.AnyOrBuilder> |
getDetailsOrBuilderList()
A list of messages that carry the error details.
|
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.
|
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 |
setMessage(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 |
setUnknownFields(com.google.protobuf.UnknownFieldSet unknownFields) |
addRepeatedField, clearField, clearOneof, clone, getAllFields, getField, getFieldBuilder, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldBuilder, getRepeatedFieldCount, getUnknownFields, hasField, hasOneof, newBuilderForField, setField, setRepeatedFieldfindInitializationErrors, getInitializationErrorString, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, toStringmergeDelimitedFrom, mergeDelimitedFrom, mergeFrompublic static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
public Status.Builder clear()
clear 在接口中 com.google.protobuf.Message.Builderclear 在接口中 com.google.protobuf.MessageLite.Builderclear 在类中 com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public com.google.protobuf.Descriptors.Descriptor getDescriptorForType()
getDescriptorForType 在接口中 com.google.protobuf.Message.BuildergetDescriptorForType 在接口中 com.google.protobuf.MessageOrBuildergetDescriptorForType 在类中 com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public Status getDefaultInstanceForType()
getDefaultInstanceForType 在接口中 com.google.protobuf.MessageLiteOrBuildergetDefaultInstanceForType 在接口中 com.google.protobuf.MessageOrBuilderpublic Status build()
build 在接口中 com.google.protobuf.Message.Builderbuild 在接口中 com.google.protobuf.MessageLite.Builderpublic Status buildPartial()
buildPartial 在接口中 com.google.protobuf.Message.BuilderbuildPartial 在接口中 com.google.protobuf.MessageLite.Builderpublic Status.Builder mergeFrom(com.google.protobuf.Message other)
mergeFrom 在接口中 com.google.protobuf.Message.BuildermergeFrom 在类中 com.google.protobuf.AbstractMessage.Builder<Status.Builder>public Status.Builder mergeFrom(Status other)
public final boolean isInitialized()
isInitialized 在接口中 com.google.protobuf.MessageLiteOrBuilderisInitialized 在类中 com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public Status.Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException
mergeFrom 在接口中 com.google.protobuf.Message.BuildermergeFrom 在接口中 com.google.protobuf.MessageLite.BuildermergeFrom 在类中 com.google.protobuf.AbstractMessage.Builder<Status.Builder>IOExceptionpublic int getCode()
The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
int32 code = 1;getCode 在接口中 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;value - The code to set.public Status.Builder clearCode()
The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
int32 code = 1;public 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 在接口中 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 在接口中 StatusOrBuilderpublic Status.Builder setMessage(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;value - The message to set.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;value - The bytes for message to set.public List<com.google.protobuf.Any> getDetailsList()
A list of messages that carry the error details. There will be a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;getDetailsList 在接口中 StatusOrBuilderpublic int getDetailsCount()
A list of messages that carry the error details. There will be a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;getDetailsCount 在接口中 StatusOrBuilderpublic com.google.protobuf.Any getDetails(int index)
A list of messages that carry the error details. There will be a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;getDetails 在接口中 StatusOrBuilderpublic Status.Builder setDetails(int index, com.google.protobuf.Any value)
A list of messages that carry the error details. There will be 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 will be 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 will be 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 will be 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 will be 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 will be a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public Status.Builder addAllDetails(Iterable<? extends com.google.protobuf.Any> values)
A list of messages that carry the error details. There will be 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 will be 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 will be 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 will be 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 will be a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;getDetailsOrBuilder 在接口中 StatusOrBuilderpublic List<? extends com.google.protobuf.AnyOrBuilder> getDetailsOrBuilderList()
A list of messages that carry the error details. There will be a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;getDetailsOrBuilderList 在接口中 StatusOrBuilderpublic com.google.protobuf.Any.Builder addDetailsBuilder()
A list of messages that carry the error details. There will be 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 will be a common set of message types for APIs to use.
repeated .google.protobuf.Any details = 3;public List<com.google.protobuf.Any.Builder> getDetailsBuilderList()
A list of messages that carry the error details. There will be 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 在接口中 com.google.protobuf.Message.BuildersetUnknownFields 在类中 com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>public final Status.Builder mergeUnknownFields(com.google.protobuf.UnknownFieldSet unknownFields)
mergeUnknownFields 在接口中 com.google.protobuf.Message.BuildermergeUnknownFields 在类中 com.google.protobuf.GeneratedMessageV3.Builder<Status.Builder>Copyright © 2011–2020 The Apache Software Foundation. All rights reserved.