errors

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 6 Imported by: 9

Documentation

Overview

Package errors implements functions for advanced error handling.

Errors in this package contain a message, a cause (an error that caused this error) and an attachment (any interface{}). Errors also contain information about the program location where they were created.

Errors can be printed using the fmt.Printf verbs %s, %q, %x, %X, %v. In particular the %+v format will print an error complete with its stack trace.

Inspired by https://github.com/pkg/errors

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attachment

func Attachment(err error) interface{}

Attachment will return additional information attached to this error (if any).

func Cause

func Cause(err error) error

Cause will return the error that caused this error (if any).

func HasAttachment

func HasAttachment(err error, attachment interface{}) bool

HasAttachment determines if a particular attachment is in the causal chain of this error.

func HasCause

func HasCause(err error, cause error) bool

HasCause determines if a particular error is in the causal chain of this error.

func New

func New(message string, args ...interface{}) error

New creates an error with a message. Additionally the error may contain a cause (an error that caused this error) and an attachment (any interface{}). New will also record information about the program location where it was called.

Types

This section is empty.

Jump to

Keyboard shortcuts

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