From b13dff85393d05243a21ac56a7a572850a3d804b Mon Sep 17 00:00:00 2001 From: lukechampine Date: Tue, 18 Jul 2017 16:11:56 -0400 Subject: [PATCH] add MmapError type --- db.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db.go b/db.go index 294d7c52..4c63dfcf 100644 --- a/db.go +++ b/db.go @@ -39,6 +39,11 @@ const ( // default page size for db is set to the OS page size. var defaultPageSize = os.Getpagesize() +// MmapError represents an error resulting from a failed mmap call. Typically, +// this error means that no further database writes will be possible. The most +// common cause is insufficient disk space. +type MmapError error + // DB represents a collection of buckets persisted to a file on disk. // All data access is performed through transactions which can be obtained through the DB. // All the functions on DB will return a ErrDatabaseNotOpen if accessed before Open() is called. @@ -280,7 +285,7 @@ func (db *DB) mmap(minsz int) error { if err2 := mmap(db, db.datasz); err2 != nil { panic(fmt.Sprintf("failed to revert db size after failed mmap: %v", err2)) } - return err + return MmapError(err) } // Save references to the meta pages.