github.com/bhojpur/cache@v0.0.4/pkg/memory/errors.go (about)

     1  package memory
     2  
     3  // Copyright (c) 2018 Bhojpur Consulting Private Limited, India. All rights reserved.
     4  
     5  // Permission is hereby granted, free of charge, to any person obtaining a copy
     6  // of this software and associated documentation files (the "Software"), to deal
     7  // in the Software without restriction, including without limitation the rights
     8  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     9  // copies of the Software, and to permit persons to whom the Software is
    10  // furnished to do so, subject to the following conditions:
    11  
    12  // The above copyright notice and this permission notice shall be included in
    13  // all copies or substantial portions of the Software.
    14  
    15  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    16  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    17  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    18  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    19  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    20  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    21  // THE SOFTWARE.
    22  
    23  import "errors"
    24  
    25  // These errors can be returned when opening or calling methods on a DB.
    26  var (
    27  	// ErrDatabaseNotOpen is returned when a DB instance is accessed before it
    28  	// is opened or after it is closed.
    29  	ErrDatabaseNotOpen = errors.New("in-memory database not open")
    30  
    31  	// ErrDatabaseOpen is returned when opening a database that is
    32  	// already open.
    33  	ErrDatabaseOpen = errors.New("in-memory database already open")
    34  
    35  	// ErrInvalid is returned when both meta pages on a database are invalid.
    36  	// This typically occurs when a file is not a Bhojpur Cache in-memory database.
    37  	ErrInvalid = errors.New("invalid in-memory database")
    38  
    39  	// ErrVersionMismatch is returned when the data file was created with a
    40  	// different version of Bhojpur Cache.
    41  	ErrVersionMismatch = errors.New("in-memory database storage engine version mismatch")
    42  
    43  	// ErrChecksum is returned when either meta page checksum does not match.
    44  	ErrChecksum = errors.New("checksum error")
    45  
    46  	// ErrTimeout is returned when a database cannot obtain an exclusive lock
    47  	// on the data file after the timeout passed to Open().
    48  	ErrTimeout = errors.New("timeout")
    49  )
    50  
    51  // These errors can occur when beginning or committing a Tx.
    52  var (
    53  	// ErrTxNotWritable is returned when performing a write operation on a
    54  	// read-only transaction.
    55  	ErrTxNotWritable = errors.New("tx not writable")
    56  
    57  	// ErrTxClosed is returned when committing or rolling back a transaction
    58  	// that has already been committed or rolled back.
    59  	ErrTxClosed = errors.New("tx closed")
    60  
    61  	// ErrDatabaseReadOnly is returned when a mutating transaction is started on a
    62  	// read-only database.
    63  	ErrDatabaseReadOnly = errors.New("in-memory database is in read-only mode")
    64  )
    65  
    66  // These errors can occur when putting or deleting a value or a bucket.
    67  var (
    68  	// ErrBucketNotFound is returned when trying to access a bucket that has
    69  	// not been created yet.
    70  	ErrBucketNotFound = errors.New("in-memory bucket not found")
    71  
    72  	// ErrBucketExists is returned when creating a bucket that already exists.
    73  	ErrBucketExists = errors.New("in-memory bucket already exists")
    74  
    75  	// ErrBucketNameRequired is returned when creating a bucket with a blank name.
    76  	ErrBucketNameRequired = errors.New("in-memory bucket name required")
    77  
    78  	// ErrKeyRequired is returned when inserting a zero-length key.
    79  	ErrKeyRequired = errors.New("key required")
    80  
    81  	// ErrKeyTooLarge is returned when inserting a key that is larger than MaxKeySize.
    82  	ErrKeyTooLarge = errors.New("key too large")
    83  
    84  	// ErrValueTooLarge is returned when inserting a value that is larger than MaxValueSize.
    85  	ErrValueTooLarge = errors.New("value too large")
    86  
    87  	// ErrIncompatibleValue is returned when trying create or delete a bucket
    88  	// on an existing non-bucket key or when trying to create or delete a
    89  	// non-bucket key on an existing bucket key.
    90  	ErrIncompatibleValue = errors.New("incompatible value")
    91  )