agherr

package
v0.106.0-b.3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package agherr contains AdGuard Home's error handling helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Annotate added in v0.106.0

func Annotate(msg string, errPtr *error, args ...interface{})

Annotate annotates the error with the message, unless the error is nil. This is a helper function to simplify code like this:

func (f *foo) doStuff(s string) (err error) {
        defer func() {
                if err != nil {
                        err = fmt.Errorf("bad foo string %q: %w", s, err)
                }
        }()

        // …
}

Instead, write:

func (f *foo) doStuff(s string) (err error) {
        defer agherr.Annotate("bad foo string %q: %w", &err, s)

        // …
}

msg must contain the final ": %w" verb.

TODO(a.garipov): Clearify the function usage.

func LogPanic added in v0.106.0

func LogPanic(prefix string)

LogPanic is a convinient helper function to log a panic in a goroutine. It should not be used where proper error handling is required.

func Many

func Many(message string, underlying ...error) (err error)

Many wraps several errors and returns a single error.

TODO(a.garipov): Add formatting to message.

Types

type Error

type Error string

Error is the constant error type.

func (Error) Error

func (err Error) Error() (msg string)

Error implements the error interface for Error.

Jump to

Keyboard shortcuts

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