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.

70 lines
2.6 KiB

  1. package bolt
  2. import "errors"
  3. // These errors can be returned when opening or calling methods on a DB.
  4. var (
  5. // ErrDatabaseNotOpen is returned when a DB instance is accessed before it
  6. // is opened or after it is closed.
  7. ErrDatabaseNotOpen = errors.New("database not open")
  8. // ErrDatabaseOpen is returned when opening a database that is
  9. // already open.
  10. ErrDatabaseOpen = errors.New("database already open")
  11. // ErrInvalid is returned when a data file is not a Bolt-formatted database.
  12. ErrInvalid = errors.New("invalid database")
  13. // ErrVersionMismatch is returned when the data file was created with a
  14. // different version of Bolt.
  15. ErrVersionMismatch = errors.New("version mismatch")
  16. // ErrChecksum is returned when either meta page checksum does not match.
  17. ErrChecksum = errors.New("checksum error")
  18. // ErrTimeout is returned when a database cannot obtain an exclusive lock
  19. // on the data file after the timeout passed to Open().
  20. ErrTimeout = errors.New("timeout")
  21. )
  22. // These errors can occur when beginning or committing a Tx.
  23. var (
  24. // ErrTxNotWritable is returned when performing a write operation on a
  25. // read-only transaction.
  26. ErrTxNotWritable = errors.New("tx not writable")
  27. // ErrTxClosed is returned when committing or rolling back a transaction
  28. // that has already been committed or rolled back.
  29. ErrTxClosed = errors.New("tx closed")
  30. // ErrDatabaseReadOnly is returned when a mutating transaction is started on a
  31. // read-only database.
  32. ErrDatabaseReadOnly = errors.New("database is in read-only mode")
  33. )
  34. // These errors can occur when putting or deleting a value or a bucket.
  35. var (
  36. // ErrBucketNotFound is returned when trying to access a bucket that has
  37. // not been created yet.
  38. ErrBucketNotFound = errors.New("bucket not found")
  39. // ErrBucketExists is returned when creating a bucket that already exists.
  40. ErrBucketExists = errors.New("bucket already exists")
  41. // ErrBucketNameRequired is returned when creating a bucket with a blank name.
  42. ErrBucketNameRequired = errors.New("bucket name required")
  43. // ErrKeyRequired is returned when inserting a zero-length key.
  44. ErrKeyRequired = errors.New("key required")
  45. // ErrKeyTooLarge is returned when inserting a key that is larger than MaxKeySize.
  46. ErrKeyTooLarge = errors.New("key too large")
  47. // ErrValueTooLarge is returned when inserting a value that is larger than MaxValueSize.
  48. ErrValueTooLarge = errors.New("value too large")
  49. // ErrIncompatibleValue is returned when trying create or delete a bucket
  50. // on an existing non-bucket key or when trying to create or delete a
  51. // non-bucket key on an existing bucket key.
  52. ErrIncompatibleValue = errors.New("incompatible value")
  53. )