wrapped

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WrapErrorFunc

type WrapErrorFunc func(err error) error

func New

func New(msg string) (base error, wrap WrapErrorFunc)

Create a function that wraps errors from third-party sources. Those wrapped errors also satisfy errors.Is(err, Base)

Base is a new well-known error that should be a public field of your package, so users can test errors.Is(err, Base)

Example:

var WrongTime, wrapWrongTime = wrapped.New("wrong time")

func foo() error {
	    ...
	    if err != nil {
	        return wrapWrongTime(err)
	    }
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL