You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

error.go 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. package bleve
  15. // Constant Error values which can be compared to determine the type of error
  16. const (
  17. ErrorIndexPathExists Error = iota
  18. ErrorIndexPathDoesNotExist
  19. ErrorIndexMetaMissing
  20. ErrorIndexMetaCorrupt
  21. ErrorUnknownStorageType
  22. ErrorIndexClosed
  23. ErrorAliasMulti
  24. ErrorAliasEmpty
  25. ErrorUnknownIndexType
  26. ErrorEmptyID
  27. ErrorIndexReadInconsistency
  28. )
  29. // Error represents a more strongly typed bleve error for detecting
  30. // and handling specific types of errors.
  31. type Error int
  32. func (e Error) Error() string {
  33. return errorMessages[e]
  34. }
  35. var errorMessages = map[Error]string{
  36. ErrorIndexPathExists: "cannot create new index, path already exists",
  37. ErrorIndexPathDoesNotExist: "cannot open index, path does not exist",
  38. ErrorIndexMetaMissing: "cannot open index, metadata missing",
  39. ErrorIndexMetaCorrupt: "cannot open index, metadata corrupt",
  40. ErrorUnknownStorageType: "unknown storage type",
  41. ErrorIndexClosed: "index is closed",
  42. ErrorAliasMulti: "cannot perform single index operation on multiple index alias",
  43. ErrorAliasEmpty: "cannot perform operation on empty alias",
  44. ErrorUnknownIndexType: "unknown index type",
  45. ErrorEmptyID: "document ID cannot be empty",
  46. ErrorIndexReadInconsistency: "index read inconsistency detected",
  47. }