public final class RequestStatusUtil
extends java.lang.Object
Constructor and Description |
---|
RequestStatusUtil() |
Modifier and Type | Method and Description |
---|---|
static SearchServicePb.RequestStatus |
newInvalidRequestStatus(java.lang.IllegalArgumentException e)
Creates a RequestStatus message suitable for reporting an invalid request.
|
static SearchServicePb.RequestStatus |
newStatus(SearchServicePb.SearchServiceError.ErrorCode code)
Creates a SearchServicePb.RequestStatus from the given code.
|
static SearchServicePb.RequestStatus |
newStatus(SearchServicePb.SearchServiceError.ErrorCode code,
java.lang.String message)
Creates a SearchServicePb.RequestStatus from the given code and message.
|
static SearchServicePb.RequestStatus.Builder |
newStatusBuilder(SearchServicePb.SearchServiceError.ErrorCode code,
java.lang.String message)
Creates a SearchServicePb.RequestStatus.Builder from the given code and message.
|
static SearchServicePb.RequestStatus |
newUnknownIndexStatus(SearchServicePb.IndexSpec indexSpec)
Creates a RequestStatus message suitable for reporting an unknown index.
|
static RequestStatus |
reduce(java.util.Collection<RequestStatus> statuses)
For a 'batch' request, determines a single status to stand for all.
|
static Code |
toCanonicalCode(SearchServicePb.SearchServiceError.ErrorCode appCode)
Converts SearchServicePb.SearchServiceError.ErrorCode to canonical error code.
|
public static Code toCanonicalCode(SearchServicePb.SearchServiceError.ErrorCode appCode)
public static SearchServicePb.RequestStatus.Builder newStatusBuilder(SearchServicePb.SearchServiceError.ErrorCode code, java.lang.String message)
public static SearchServicePb.RequestStatus newStatus(SearchServicePb.SearchServiceError.ErrorCode code, java.lang.String message)
public static SearchServicePb.RequestStatus newStatus(SearchServicePb.SearchServiceError.ErrorCode code)
public static SearchServicePb.RequestStatus newInvalidRequestStatus(java.lang.IllegalArgumentException e)
public static SearchServicePb.RequestStatus newUnknownIndexStatus(SearchServicePb.IndexSpec indexSpec)
SearchServicePb.SearchServiceError.ErrorCode#OK
because the unknown index isn't
an error condition but just a notice to the user.public static RequestStatus reduce(java.util.Collection<RequestStatus> statuses)
If the collection is empty, the result will be an OK status with no detail.
If the collection has one element, the result will be that element.
If the collection has multiple elements with the same error code, the result will have that error code and the corresponding canonical code.
If there are multiple error statuses in the collection, the one with the highest numerical code in the ErrorCode enum will be chosen as representative, and the errorDetail field of the result will contain at least the errorDetail of that status.