Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



The rest of this page describes the structure of an error, enumerates specific error codes and how to handle them, and shows how to handle errors using the Datastore client libraries.

  1. Error Structure
  2. Error Codes
  3. Error Handling in Client Libraries

Error Structure

Here's an example of an error response:
{
  "error": {
    "errors": [
     {
       "domain": "global",
       "reason": "INVALID_ARGUMENT",
       "message": "Key path is incomplete: [Person: null]"
     }
    ],
    "code": 400,
    "message": "Key path is incomplete: [Person: null]"
  }
}

Note: The message could change at any time so applications should not depend on the actual message text.

Error Codes

Reason HTTP Status Code Description Recommended Action
ABORTED 409 Indicates that the request conflicted with another request. Retry the request or structure your entities to reduce contention. For more information, see Transactions .
DEADLINE_EXCEEDED 403 A deadline was exceeded on the server. Retry using exponential backoff.
FAILED_PRECONDITION 412 Indicates that a precondition for the request was not met. The message field in the error response provides information about the precondition that failed. Do not retry without fixing the problem.
INTERNAL 500 Server returned an error. Do not retry this request more than once.
INVALID_ARGUMENT 400 Indicates that a request parameter has an invalid value. The message field in the error response provides information as to which value was invalid. Do not retry without fixing the problem.
PERMISSION_DENIED 403 Indicates that the user was not authorized to make the request. Do not retry without fixing the problem.
RESOURCE_EXHAUSTED 402 Indicates that the user has exceeded the project quota. Do not retry without fixing the problem.
UNAVAILABLE 503 Server returned an error. Retry using exponential backoff.

Error Handling in Client Libraries

The following snippet shows how to catch and parse an error using the Datastore client library.

Python (Protocol Buffers)

try:
  self.datastore.commit(req)
except datastore.RPCError as e:
  code = e.response.status
  method = e.method
  error = json.loads(e.reason)['error']['errors'][0]
  reason = error['reason']
  message = error['message']
  # ... process error ...

Java (Protocol Buffers)

try {
  commitResponse = datastore.commit(commitRequest);
} catch (DatastoreException e) {
  int code = e.getCode();
  String method = e.getMethodName();
  JSONObject json = new JSONObject(new JSONTokener(e.getMessage()));
  JSONObject error = json.getJSONObject("error")
      .getJSONArray("errors")
      .getJSONObject(0);
  String reason = error.getString("reason");
  String message = error.getString("message");
  // ... process error ...
}

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.