Scott Baker | 8487c5d | 2019-10-18 12:49:46 -0700 | [diff] [blame] | 1 | package lz4 |
| 2 | |
| 3 | import ( |
| 4 | "errors" |
| 5 | "fmt" |
| 6 | "os" |
| 7 | rdebug "runtime/debug" |
| 8 | ) |
| 9 | |
| 10 | var ( |
| 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 | // 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") |
| 20 | ) |
| 21 | |
| 22 | func recoverBlock(e *error) { |
| 23 | if r := recover(); r != nil && *e == nil { |
| 24 | if debugFlag { |
| 25 | fmt.Fprintln(os.Stderr, r) |
| 26 | rdebug.PrintStack() |
| 27 | } |
| 28 | *e = ErrInvalidSourceShortBuffer |
| 29 | } |
| 30 | } |