1//  Copyright (c) 2014 Couchbase, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// 		http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package bleve
16
17// Constant Error values which can be compared to determine the type of error
18const (
19	ErrorIndexPathExists Error = iota
20	ErrorIndexPathDoesNotExist
21	ErrorIndexMetaMissing
22	ErrorIndexMetaCorrupt
23	ErrorUnknownStorageType
24	ErrorIndexClosed
25	ErrorAliasMulti
26	ErrorAliasEmpty
27	ErrorUnknownIndexType
28	ErrorEmptyID
29	ErrorIndexReadInconsistency
30)
31
32// Error represents a more strongly typed bleve error for detecting
33// and handling specific types of errors.
34type Error int
35
36func (e Error) Error() string {
37	return errorMessages[e]
38}
39
40var errorMessages = map[Error]string{
41	ErrorIndexPathExists:        "cannot create new index, path already exists",
42	ErrorIndexPathDoesNotExist:  "cannot open index, path does not exist",
43	ErrorIndexMetaMissing:       "cannot open index, metadata missing",
44	ErrorIndexMetaCorrupt:       "cannot open index, metadata corrupt",
45	ErrorUnknownStorageType:     "unknown storage type",
46	ErrorIndexClosed:            "index is closed",
47	ErrorAliasMulti:             "cannot perform single index operation on multiple index alias",
48	ErrorAliasEmpty:             "cannot perform operation on empty alias",
49	ErrorUnknownIndexType:       "unknown index type",
50	ErrorEmptyID:                "document ID cannot be empty",
51	ErrorIndexReadInconsistency: "index read inconsistency detected",
52}
53