globals.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * EliasDB
  3. *
  4. * Copyright 2016 Matthias Ladkau. All rights reserved.
  5. *
  6. * This Source Code Form is subject to the terms of the Mozilla Public
  7. * License, v. 2.0. If a copy of the MPL was not distributed with this
  8. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. */
  10. package storage
  11. import (
  12. "errors"
  13. "fmt"
  14. "devt.de/krotik/common/pools"
  15. )
  16. /*
  17. BufferPool is a pool of byte buffers.
  18. */
  19. var BufferPool = pools.NewByteBufferPool()
  20. /*
  21. Common storage manager related errors.
  22. */
  23. var (
  24. ErrSlotNotFound = errors.New("Slot not found")
  25. ErrNotInCache = errors.New("No entry in cache")
  26. )
  27. /*
  28. ManagerError is a storage manager related error.
  29. */
  30. type ManagerError struct {
  31. Type error
  32. Detail string
  33. Managername string
  34. }
  35. /*
  36. NewStorageManagerError returns a new StorageManager specific error.
  37. */
  38. func NewStorageManagerError(smeType error, smeDetail string, smeManagername string) *ManagerError {
  39. return &ManagerError{smeType, smeDetail, smeManagername}
  40. }
  41. /*
  42. Error returns a string representation of the error.
  43. */
  44. func (e *ManagerError) Error() string {
  45. return fmt.Sprintf("%s (%s - %s)", e.Type.Error(), e.Managername, e.Detail)
  46. }