package errors
import "github.com/grufwub/go-errors"
Index ¶
- func Is(err, target error) bool
- type BaseError
- func BaseErrorf(s string, a ...interface{}) BaseError
- func (e BaseError) Error() string
- func (e BaseError) Extend(a ...interface{}) Error
- func (e BaseError) Extendf(s string, a ...interface{}) Error
- func (e BaseError) Is(target error) bool
- func (e BaseError) Original() error
- func (e BaseError) Unwrap() error
- func (e BaseError) Wrap(err error) Error
- func (e BaseError) WrapWithin(err error) Error
- type Error
Functions ¶
func Is ¶
Is wraps "errors".Is()
Types ¶
type BaseError ¶
type BaseError string
BaseError is an error type that supports being defined as `const`, as it is simply a string typedef
func BaseErrorf ¶
BaseErrorf returns a new BaseError based on the supplied format string
func (BaseError) Error ¶
func (BaseError) Extend ¶
func (BaseError) Extendf ¶
func (BaseError) Is ¶
func (BaseError) Original ¶
func (BaseError) Unwrap ¶
func (BaseError) Wrap ¶
func (BaseError) WrapWithin ¶
type Error ¶
type Error interface { // Error returns the error string Error() string // Is returns whether an error is of type [supplied target] Is(error) bool // Original returns the original error, i.e. without any of our wrappers // providing extra methods // // e.g. // er := errors.With(library.ErrSomeIssue).Extend("more text!") // og := er.Original() // // switch library.ErrSomeIssue { // case er: // // we will never reach here // case og: // // this is the original error! // } Original() error // Unwrap attempts to unwrap any internally wrapped errors // // e.g. // err1 := errors.BaseError("bad error oh noes") // err2 := err1.WrapWithin(library.ErrSomeIssue) // // if err2.Unwrap() == err1 { // // this is true! // } Unwrap() error // Extend extends an error with extra information Extend(...interface{}) Error // Extendf extends an error with extra information using format strings Extendf(string, ...interface{}) Error // Wrap wraps the current error within a wrapper, using the originating // error-in-wrapper as the outer error Wrap(error) Error // WrapWithin wraps the originating error within a wrapper, using the // supplied error-in-wrapper as the outer error WrapWithin(error) Error }
Error defines an error interface with helper functions for extending with extra information, wrapping within errors, and .Is() .Unwrap() to support standard "errors" library utilities.
func With ¶
With wraps a non errors.Error type error within an errors.Error interface
Source Files ¶
- Version
- v0.3.4 (latest)
- Published
- Feb 21, 2021
- Platform
- linux/amd64
- Imports
- 2 packages
- Last checked
- 1 month ago –
Tools for package owners.