Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / datastore / DatastoreNeedIndexException.java
blob5a821fac41d3973e86d442f696f18b6d12703f05
1 // Copyright 2008 Google Inc. All Rights Reserved.
2 package com.google.appengine.api.datastore;
4 /**
5 * {@code DatastoreNeedIndexException} is thrown when no matching index was
6 * found for a query requiring an index. Check the Indexes page in the Admin
7 * Console and your datastore-indexes.xml file.
9 */
10 public class DatastoreNeedIndexException extends RuntimeException {
12 static final long serialVersionUID = 9218197931741583584L;
14 static final String NO_XML_MESSAGE = "\nAn index is missing but we are unable to tell you which "
15 + "one due to a bug in the App Engine SDK. If your query only contains equality filters you "
16 + "most likely need a composite index on all the properties referenced in those filters.";
18 String xml;
20 public DatastoreNeedIndexException(String message) {
21 super(message);
24 @Override
25 public String getMessage() {
26 return super.getMessage() + (xml == null ? NO_XML_MESSAGE :
27 "\nThe suggested index for this query is:\n" + xml);
30 /**
31 * @return The xml defining the missing index. Can be {@code null}.
33 public String getMissingIndexDefinitionXml() {
34 return xml;
37 void setMissingIndexDefinitionXml(String xml) {
38 this.xml = xml;