Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gz/zlib/flate: Alias stdlib errors #425

Merged
merged 1 commit into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 4 additions & 22 deletions flate/inflate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ package flate

import (
"bufio"
"compress/flate"
"fmt"
"io"
"math/bits"
"strconv"
"sync"
)

Expand Down Expand Up @@ -41,11 +41,7 @@ var fixedOnce sync.Once
var fixedHuffmanDecoder huffmanDecoder

// A CorruptInputError reports the presence of corrupt input at a given offset.
type CorruptInputError int64

func (e CorruptInputError) Error() string {
return "flate: corrupt input before offset " + strconv.FormatInt(int64(e), 10)
}
type CorruptInputError = flate.CorruptInputError

// An InternalError reports an error in the flate code itself.
type InternalError string
Expand All @@ -55,26 +51,12 @@ func (e InternalError) Error() string { return "flate: internal error: " + strin
// A ReadError reports an error encountered while reading input.
//
// Deprecated: No longer returned.
type ReadError struct {
Offset int64 // byte offset where error occurred
Err error // error returned by underlying Read
}

func (e *ReadError) Error() string {
return "flate: read error at offset " + strconv.FormatInt(e.Offset, 10) + ": " + e.Err.Error()
}
type ReadError = flate.ReadError

// A WriteError reports an error encountered while writing output.
//
// Deprecated: No longer returned.
type WriteError struct {
Offset int64 // byte offset where error occurred
Err error // error returned by underlying Write
}

func (e *WriteError) Error() string {
return "flate: write error at offset " + strconv.FormatInt(e.Offset, 10) + ": " + e.Err.Error()
}
type WriteError = flate.WriteError

// Resetter resets a ReadCloser returned by NewReader or NewReaderDict to
// to switch to a new underlying Reader. This permits reusing a ReadCloser
Expand Down
6 changes: 3 additions & 3 deletions gzip/gunzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ package gzip

import (
"bufio"
"compress/gzip"
"encoding/binary"
"errors"
"hash/crc32"
"io"
"time"
Expand All @@ -30,9 +30,9 @@ const (

var (
// ErrChecksum is returned when reading GZIP data that has an invalid checksum.
ErrChecksum = errors.New("gzip: invalid checksum")
ErrChecksum = gzip.ErrChecksum
// ErrHeader is returned when reading GZIP data that has an invalid header.
ErrHeader = errors.New("gzip: invalid header")
ErrHeader = gzip.ErrHeader
)

var le = binary.LittleEndian
Expand Down
8 changes: 4 additions & 4 deletions zlib/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ package zlib

import (
"bufio"
"errors"
"compress/zlib"
"hash"
"hash/adler32"
"io"
Expand All @@ -37,11 +37,11 @@ const zlibDeflate = 8

var (
// ErrChecksum is returned when reading ZLIB data that has an invalid checksum.
ErrChecksum = errors.New("zlib: invalid checksum")
ErrChecksum = zlib.ErrChecksum
// ErrDictionary is returned when reading ZLIB data that has an invalid dictionary.
ErrDictionary = errors.New("zlib: invalid dictionary")
ErrDictionary = zlib.ErrDictionary
// ErrHeader is returned when reading ZLIB data that has an invalid header.
ErrHeader = errors.New("zlib: invalid header")
ErrHeader = zlib.ErrHeader
)

type reader struct {
Expand Down