Exception DatastoreException (2.37.0)

public final class DatastoreException extends BaseHttpServiceException

Datastore service exception. See Also: Google Cloud Datastore error codes

Static Methods

extractStatusCode(Throwable throwable)

public static String extractStatusCode(Throwable throwable)

Extracts the status code name from the given throwable. Walks the exception cause chain looking for a DatastoreException that carries a reason string representing the status code (e.g. "ABORTED", "UNAVAILABLE"). The reason is set from com.google.api.gax.rpc.StatusCode.Code which is transport-neutral, supporting both gRPC and HttpJson. Falls back to "UNKNOWN" if the status cannot be determined.

Note: Some DatastoreException instances are constructed without a reason (e.g. via DatastoreException#DatastoreException(int, String, Throwable)). If all DatastoreException instances in the cause chain have a null or empty reason, this method returns "UNKNOWN" even if the underlying error carries a meaningful status.

Parameter
Name Description
throwable Throwable

the throwable to extract the status code from

Returns
Type Description
String

the status code name, or "UNKNOWN" if not determinable

Constructors

DatastoreException(int code, String message, String reason)

public DatastoreException(int code, String message, String reason)
Parameters
Name Description
code int
message String
reason String

DatastoreException(int code, String message, String reason, boolean idempotent, Throwable cause)

public DatastoreException(int code, String message, String reason, boolean idempotent, Throwable cause)
Parameters
Name Description
code int
message String
reason String
idempotent boolean
cause Throwable

DatastoreException(int code, String message, String reason, Throwable cause)

public DatastoreException(int code, String message, String reason, Throwable cause)
Parameters
Name Description
code int
message String
reason String
cause Throwable

DatastoreException(int code, String message, Throwable cause)

public DatastoreException(int code, String message, Throwable cause)
Parameters
Name Description
code int
message String
cause Throwable

DatastoreException(IOException exception)

public DatastoreException(IOException exception)
Parameter
Name Description
exception IOException