aboutsummaryrefslogtreecommitdiff
path: root/error.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-02-12 14:57:27 -0700
committerBen Johnson <benbjohnson@yahoo.com>2014-02-13 10:58:27 -0700
commit8ad59edd02a8ea6001f15cd6d92944ae83c88f6d (patch)
tree3597cf9a764ba9e99779477a70f7bb71848d1a4c /error.go
parentMmap remap. (diff)
downloaddedo-8ad59edd02a8ea6001f15cd6d92944ae83c88f6d.tar.gz
dedo-8ad59edd02a8ea6001f15cd6d92944ae83c88f6d.tar.xz
API Documentation.
Diffstat (limited to 'error.go')
-rw-r--r--error.go46
1 files changed, 39 insertions, 7 deletions
diff --git a/error.go b/error.go
index b5302ad..519309f 100644
--- a/error.go
+++ b/error.go
@@ -1,20 +1,52 @@
package bolt
var (
- InvalidError = &Error{"Invalid database", nil}
- VersionMismatchError = &Error{"version mismatch", nil}
- DatabaseNotOpenError = &Error{"db is not open", nil}
- DatabaseAlreadyOpenedError = &Error{"db already open", nil}
- TransactionInProgressError = &Error{"writable transaction is already in progress", nil}
- InvalidTransactionError = &Error{"txn is invalid", nil}
- BucketAlreadyExistsError = &Error{"bucket already exists", nil}
+ // InvalidError is returned when a data file is not a Bolt-formatted database.
+ InvalidError = &Error{"Invalid database", nil}
+
+ // VersionMismatchError is returned when the data file was created with a
+ // different version of Bolt.
+ VersionMismatchError = &Error{"version mismatch", nil}
+
+ // DatabaseNotOpenError is returned when a DB instance is accessed before it
+ // is opened or after it is closed.
+ DatabaseNotOpenError = &Error{"database not open", nil}
+
+ // DatabaseOpenError is returned when opening a database that is
+ // already open.
+ DatabaseOpenError = &Error{"database already open", nil}
+
+ // BucketNotFoundError is returned when trying to access a bucket that has
+ // not been created yet.
+ BucketNotFoundError = &Error{"bucket not found", nil}
+
+ // BucketExistsError is returned when creating a bucket that already exists.
+ BucketExistsError = &Error{"bucket already exists", nil}
+
+ // BucketNameRequiredError is returned when creating a bucket with a blank name.
+ BucketNameRequiredError = &Error{"bucket name required", nil}
+
+ // BucketNameTooLargeError is returned when creating a bucket with a name
+ // that is longer than MaxBucketNameSize.
+ BucketNameTooLargeError = &Error{"bucket name too large", nil}
+
+ // KeyRequiredError is returned when inserting a zero-length key.
+ KeyRequiredError = &Error{"key required", nil}
+
+ // KeyTooLargeError is returned when inserting a key that is larger than MaxKeySize.
+ KeyTooLargeError = &Error{"key too large", nil}
+
+ // ValueTooLargeError is returned when inserting a value that is larger than MaxValueSize.
+ ValueTooLargeError = &Error{"value too large", nil}
)
+// Error represents an error condition caused by Bolt.
type Error struct {
message string
cause error
}
+// Error returns a string representation of the error.
func (e *Error) Error() string {
if e.cause != nil {
return e.message + ": " + e.cause.Error()