Scott Baker | ed4efab | 2020-01-13 19:12:25 -0800 | [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") |
divyadesai | 1900913 | 2020-03-04 12:58:08 +0000 | [diff] [blame^] | 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") |
Scott Baker | ed4efab | 2020-01-13 19:12:25 -0800 | [diff] [blame] | 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 | } |