errors

package module
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2025 License: MIT Imports: 2 Imported by: 18

README

Documentation Go workflow CircleCI codecov Go Report Card GitHub tag (latest SemVer)

errors

errors is a wrapper around the standard errors.New and fmt.Errorf functions. It unifies their APIs, allowing you to create new errors or wrap existing ones with rich context (formatted message with arguments).

It provides two core functions:

errors.New(format string, args ...any) error
errors.Wrap(err error, format string, args ...any) error

While it previously had more features, I eventually realized that, in most cases, anything beyond simple error wrapping is an overcomplication.

Documentation

Overview

Package errors is a minimal wrapper around the standard library errors package. It changes the API from New(msg string) and fmt.Errorf(format string, args ...any) to unified New(format string, args ...any) and Wrap(err error, format string, args ...any) functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(err error, target any) bool

func Is

func Is(err, target error) bool

func New

func New(format string, args ...any) error

func Unwrap

func Unwrap(err error) error

func Wrap

func Wrap(err error, format string, args ...any) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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