gooseberry: github.com/voicera/gooseberry/errors Index | Examples | Files

package errors

import "github.com/voicera/gooseberry/errors"

Package errors provides utilities for error handling.

Index

Examples

Package Files

errors.go

func PanicIfNotNil Uses

func PanicIfNotNil(err error)

PanicIfNotNil panics if the specified error is not nil.

type AggregateError Uses

type AggregateError struct {
    Header string
    Errors []error
}

AggregateError represents an aggregate error.

Code:

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

Output:

the following errors occurred:
foo
bar

Code:

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?

Code:

err := NewAggregateError("", errors.New("foo"), errors.New("bar"))
fmt.Println(err)

Output:

foo
bar

func NewAggregateError Uses

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

NewAggregateError creates a new aggregate error with the specified header.

func (*AggregateError) Error Uses

func (aggregateError *AggregateError) Error() string

type ErrorString Uses

type ErrorString string

ErrorString is a trivial implementation of error.

func (ErrorString) Error Uses

func (err ErrorString) Error() string

Code:

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.

Package errors imports 3 packages (graph) and is imported by 1 packages. Updated 2019-01-19. Refresh now. Tools for package owners.