errors.go 1.0 KB

123456789101112131415161718192021222324252627282930
  1. package lz4
  2. import (
  3. "errors"
  4. "fmt"
  5. "os"
  6. rdebug "runtime/debug"
  7. )
  8. var (
  9. // ErrInvalidSourceShortBuffer is returned by UncompressBlock or CompressBLock when a compressed
  10. // block is corrupted or the destination buffer is not large enough for the uncompressed data.
  11. ErrInvalidSourceShortBuffer = errors.New("lz4: invalid source or destination buffer too short")
  12. // ErrInvalid is returned when reading an invalid LZ4 archive.
  13. ErrInvalid = errors.New("lz4: bad magic number")
  14. // ErrBlockDependency is returned when attempting to decompress an archive created with block dependency.
  15. ErrBlockDependency = errors.New("lz4: block dependency not supported")
  16. // ErrUnsupportedSeek is returned when attempting to Seek any way but forward from the current position.
  17. ErrUnsupportedSeek = errors.New("lz4: can only seek forward from io.SeekCurrent")
  18. )
  19. func recoverBlock(e *error) {
  20. if r := recover(); r != nil && *e == nil {
  21. if debugFlag {
  22. fmt.Fprintln(os.Stderr, r)
  23. rdebug.PrintStack()
  24. }
  25. *e = ErrInvalidSourceShortBuffer
  26. }
  27. }