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 ¶
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.
Click to show internal directories.
Click to hide internal directories.