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