Skip to content

Commit 340abd7

Browse files
committed
improve decompression errors
1 parent 52879db commit 340abd7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

huffman.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package huffman
22

33
import (
4-
"errors"
4+
"fmt"
55
)
66

77
const (
@@ -76,7 +76,7 @@ func (huff *Huffman) Decompress(data []byte) ([]byte, error) {
7676
}
7777

7878
if n == nil {
79-
return nil, errors.New("failed to decompress data: node is nil")
79+
return nil, fmt.Errorf("%w: node is nil", ErrHuffmanDecompress)
8080
}
8181

8282
if n.NumBits != 0 {
@@ -97,7 +97,7 @@ func (huff *Huffman) Decompress(data []byte) ([]byte, error) {
9797
}
9898

9999
if bitcount == 0 {
100-
return nil, errors.New("decoding error: no more bits")
100+
return nil, fmt.Errorf("%w: no more bits", ErrHuffmanDecompress)
101101
}
102102
}
103103
}

0 commit comments

Comments
 (0)