Documentation ¶
Overview ¶
Package errors implements functions to manipulate compression errors.
In idiomatic Go, it is an anti-pattern to use panics as a form of error reporting in the API. Instead, the expected way to transmit errors is by returning an error value. Unfortunately, the checking of "err != nil" in tight loops commonly found in compression causes non-negligible performance degradation. While this may not be idiomatic, the internal packages of this repository rely on panics as a normal means to convey errors. In order to ensure that these panics do not leak across the public API, the public packages must recover from these panics and present an error value.
The Panic and Recover functions in this package provide a safe way to recover from errors only generated from within this repository.
Example usage:
func Foo() (err error) { defer errors.Recover(&err) if rand.Intn(2) == 0 { // Unexpected panics will not be caught by Recover. io.Closer(nil).Close() } else { // Errors thrown by Panic will be caught by Recover. errors.Panic(errors.New("whoopsie")) } }
Index ¶
Constants ¶
const ( // Unknown indicates that there is no classification for this error. Unknown = iota // Internal indicates that this error is due to an internal bug. // Users should file a issue report if this type of error is encountered. Internal // Invalid indicates that this error is due to the user misusing the API // and is indicative of a bug on the user's part. Invalid // Deprecated indicates the use of a deprecated and unsupported feature. Deprecated // Corrupted indicates that the input stream is corrupted. Corrupted // Closed indicates that the handlers are closed. Closed )
Variables ¶
This section is empty.
Functions ¶
func IsCorrupted ¶
func IsDeprecated ¶
func IsInternal ¶
Types ¶
type Error ¶
type Error struct { Code int // The error type Pkg string // Name of the package where the error originated Msg string // Descriptive message about the error (optional) }
func (Error) CompressError ¶
func (e Error) CompressError()