errors

package
v0.0.0-...-dc23390 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2018 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package errors provides utilities for error handling.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func PanicIfNotNil

func PanicIfNotNil(err error)

PanicIfNotNil panics if the specified error is not nil.

Types

type AggregateError

type AggregateError struct {
	Header string
	Errors []error
}

AggregateError represents an aggregate error.

Example
err := NewAggregateError("the following errors occurred:", errors.New("foo"), errors.New("bar"))
fmt.Println(err)
Output:

the following errors occurred:
foo
bar
Example (HeaderOnly)
err := NewAggregateError("why would you use an aggregate error in this case?")
fmt.Println(err)
Output:

why would you use an aggregate error in this case?
Example (WithoutHeader)
err := NewAggregateError("", errors.New("foo"), errors.New("bar"))
fmt.Println(err)
Output:

foo
bar

func NewAggregateError

func NewAggregateError(header string, errors ...error) *AggregateError

NewAggregateError creates a new aggregate error with the specified header.

func (*AggregateError) Error

func (aggregateError *AggregateError) Error() string

type ErrorString

type ErrorString string

ErrorString is a trivial implementation of error.

func (ErrorString) Error

func (err ErrorString) Error() string
Example
var err ErrorString = "I'm sorry, Dave. I'm afraid I can't do that."
fmt.Println(err.Error())
Output:

I'm sorry, Dave. I'm afraid I can't do that.

Jump to

Keyboard shortcuts

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