Index: impl/memory/datastore_index_selection.go |
diff --git a/impl/memory/datastore_index_selection.go b/impl/memory/datastore_index_selection.go |
index 06516d39ff98e841b94725a69042a78772c7bc19..fc4b2b66199aeecf3f5ba7cdf639a06a313d0ab0 100644 |
--- a/impl/memory/datastore_index_selection.go |
+++ b/impl/memory/datastore_index_selection.go |
@@ -15,6 +15,22 @@ import ( |
"github.com/luci/luci-go/common/stringset" |
) |
+// ErrMissingIndex is returned when the current indexes are not sufficient |
+// for the current query. |
+type ErrMissingIndex struct { |
+ ns string |
+ Missing *ds.IndexDefinition |
+} |
+ |
+func (e *ErrMissingIndex) Error() string { |
+ yaml, err := e.Missing.YAMLString() |
+ if err != nil { |
+ panic(err) |
+ } |
+ return fmt.Sprintf( |
+ "Insufficient indexes. Consider adding:\n%s", yaml) |
+} |
+ |
var bjoin = serialize.Join |
// reducedQuery contains only the pieces of the query necessary to iterate for |
@@ -301,8 +317,7 @@ func getRelevantIndexes(q *reducedQuery, s *memStore) (indexDefinitionSortableSl |
impossible( |
fmt.Errorf("recommended missing index would be a builtin: %s", remains)) |
} |
- return nil, fmt.Errorf( |
- "Your indexes are insufficient! Try adding:\n %s", remains) |
+ return nil, &ErrMissingIndex{q.ns, remains} |
} |
return idxs, nil |