AppSearchResult
public final class AppSearchResult<ValueType>
Information about the success or failure of an AppSearch call.
| Parameters | |
|---|---|
<ValueType> |
The type of result object for successful calls. |
Summary
Constants |
|
|---|---|
static final int |
The operation is invalid because the resource already exists and can't be replaced. |
static final int |
The requested operation is denied for the caller. |
static final int |
An internal error occurred within AppSearch, which the caller cannot address. |
static final int |
The caller supplied invalid arguments to the call. |
static final int |
The caller supplied a schema which is invalid or incompatible with the previous schema. |
static final int |
RESULT_IO_ERROR = 4An issue occurred reading or writing to storage. |
static final int |
RESULT_NOT_FOUND = 6An entity the caller requested to interact with does not exist in the system. |
static final int |
RESULT_OK = 0The call was successful. |
static final int |
Storage is out of space, and no more space could be reclaimed. |
static final int |
The caller has hit AppSearch's rate limit and the requested operation has been rejected. |
static final int |
The caller requested an operation it does not have privileges for. |
static final int |
An unknown error occurred while processing the call. |
Public methods |
|
|---|---|
boolean |
|
@Nullable String |
Returns the error message associated with this result. |
int |
Returns one of the |
@Nullable ValueType |
Returns the result value associated with this result, if it was successful. |
int |
hashCode() |
boolean |
Returns |
static @NonNull AppSearchResult<ValueType> |
<ValueType> newFailedResult(int resultCode, @Nullable String errorMessage)Creates a new failed |
static @NonNull AppSearchResult<ValueType> |
<ValueType> newSuccessfulResult(@Nullable ValueType value)Creates a new successful |
@NonNull String |
toString() |
Constants
RESULT_ALREADY_EXISTS
@ExperimentalAppSearchApi
public static final int RESULT_ALREADY_EXISTS = 12
The operation is invalid because the resource already exists and can't be replaced.
RESULT_DENIED
@ExperimentalAppSearchApi
public static final int RESULT_DENIED = 9
The requested operation is denied for the caller. This error is logged and returned for denylist rejections.
RESULT_INTERNAL_ERROR
public static final int RESULT_INTERNAL_ERROR = 2
An internal error occurred within AppSearch, which the caller cannot address. This error may be considered similar to IllegalStateException
RESULT_INVALID_ARGUMENT
public static final int RESULT_INVALID_ARGUMENT = 3
The caller supplied invalid arguments to the call. This error may be considered similar to IllegalArgumentException.
RESULT_INVALID_SCHEMA
public static final int RESULT_INVALID_SCHEMA = 7
The caller supplied a schema which is invalid or incompatible with the previous schema.
RESULT_IO_ERROR
public static final int RESULT_IO_ERROR = 4
An issue occurred reading or writing to storage. The call might succeed if repeated. This error may be considered similar to java.io.IOException.
RESULT_NOT_FOUND
public static final int RESULT_NOT_FOUND = 6
An entity the caller requested to interact with does not exist in the system.
RESULT_OUT_OF_SPACE
public static final int RESULT_OUT_OF_SPACE = 5
Storage is out of space, and no more space could be reclaimed.
RESULT_RATE_LIMITED
@ExperimentalAppSearchApi
public static final int RESULT_RATE_LIMITED = 10
The caller has hit AppSearch's rate limit and the requested operation has been rejected. The caller is recommended to reschedule tasks with exponential backoff.
RESULT_SECURITY_ERROR
public static final int RESULT_SECURITY_ERROR = 8
The caller requested an operation it does not have privileges for.
RESULT_UNKNOWN_ERROR
public static final int RESULT_UNKNOWN_ERROR = 1
An unknown error occurred while processing the call.
Public methods
getErrorMessage
public @Nullable String getErrorMessage()
Returns the error message associated with this result.
If isSuccess is true, the error message is always null. The error message may be null even if isSuccess is false. See the documentation of the particular AppSearchSession call producing this AppSearchResult for what is returned by getErrorMessage.
getResultCode
public int getResultCode()
Returns one of the RESULT constants defined in AppSearchResult.
getResultValue
public @Nullable ValueType getResultValue()
Returns the result value associated with this result, if it was successful.
See the documentation of the particular AppSearchSession call producing this AppSearchResult for what is placed in the result value by that call.
| Throws | |
|---|---|
java.lang.IllegalStateException |
if this |
newFailedResult
public static @NonNull AppSearchResult<ValueType> <ValueType> newFailedResult(int resultCode, @Nullable String errorMessage)
Creates a new failed AppSearchResult.
| Parameters | |
|---|---|
int resultCode |
One of the constants documented in |
@Nullable String errorMessage |
An optional string describing the reason or nature of the failure. |
newSuccessfulResult
public static @NonNull AppSearchResult<ValueType> <ValueType> newSuccessfulResult(@Nullable ValueType value)
Creates a new successful AppSearchResult.
| Parameters | |
|---|---|
@Nullable ValueType value |
An optional value to associate with the successful result of the operation being performed. |