blob: 1c45d1813cef42940784297b0043197f43cafb85 [file] [log] [blame]
Abhilash S.L3b494632019-07-16 15:51:09 +05301package lz4
2
David Bainbridge788e5202019-10-21 18:49:40 +00003import (
4 "errors"
5 "fmt"
6 "os"
7 rdebug "runtime/debug"
8)
Abhilash S.L3b494632019-07-16 15:51:09 +05309
10var (
11 // ErrInvalidSourceShortBuffer is returned by UncompressBlock or CompressBLock when a compressed
12 // block is corrupted or the destination buffer is not large enough for the uncompressed data.
13 ErrInvalidSourceShortBuffer = errors.New("lz4: invalid source or destination buffer too short")
14 // ErrInvalid is returned when reading an invalid LZ4 archive.
15 ErrInvalid = errors.New("lz4: bad magic number")
16 // ErrBlockDependency is returned when attempting to decompress an archive created with block dependency.
17 ErrBlockDependency = errors.New("lz4: block dependency not supported")
David Bainbridge788e5202019-10-21 18:49:40 +000018 // ErrUnsupportedSeek is returned when attempting to Seek any way but forward from the current position.
19 ErrUnsupportedSeek = errors.New("lz4: can only seek forward from io.SeekCurrent")
Abhilash S.L3b494632019-07-16 15:51:09 +053020)
21
22func recoverBlock(e *error) {
David Bainbridge788e5202019-10-21 18:49:40 +000023 if r := recover(); r != nil && *e == nil {
24 if debugFlag {
25 fmt.Fprintln(os.Stderr, r)
26 rdebug.PrintStack()
27 }
Abhilash S.L3b494632019-07-16 15:51:09 +053028 *e = ErrInvalidSourceShortBuffer
29 }
30}