blob: 3e278945ec81a9a89d5af2c8585ab5189218b6cf [file] [log] [blame]
Dinesh Belwalkare63f7f92019-11-22 23:11:16 +00001package lz4
2
3import (
4 "errors"
5 "fmt"
6 "os"
7 rdebug "runtime/debug"
8)
9
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")
18)
19
20func recoverBlock(e *error) {
21 if r := recover(); r != nil && *e == nil {
22 if debugFlag {
23 fmt.Fprintln(os.Stderr, r)
24 rdebug.PrintStack()
25 }
26 *e = ErrInvalidSourceShortBuffer
27 }
28}