Documentation
¶
Overview ¶
Package errors offers an extension of functionality to the default golang errors package.
Index ¶
- type CompositeError
- func (ce *CompositeError) Add(newError error)
- func (ce *CompositeError) AddMessage(message string)
- func (ce *CompositeError) Error() string
- func (ce *CompositeError) Initialise(text string) *CompositeError
- func (ce *CompositeError) MarshalJSON() ([]byte, error)
- func (ce *CompositeError) Size() int
- func (ce *CompositeError) SubError(index int) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompositeError ¶
type CompositeError struct {
// contains filtered or unexported fields
}
CompositeError allows a number of errors to be collected together and treated as if they were a single error.
func New ¶
func New(text string) *CompositeError
New returns a new CompositeError. The text parameter supplied is used as a prefix when reporting a list of errors.
func (*CompositeError) Add ¶
func (ce *CompositeError) Add(newError error)
Add includes newError as one of the sub-errors of a CompositeError
Example ¶
newComposite := New("error prefix") newComposite.Add(errors.New("first error")) newComposite.Add(errors.New("second error")) fmt.Printf("%v", newComposite)
Output: error prefix, composed of: [ first error second error ]
func (*CompositeError) AddMessage ¶
func (ce *CompositeError) AddMessage(message string)
Add combines the supplied message as a new built-in error to the array of sub-errors of a CompositeError
func (*CompositeError) Error ¶
func (ce *CompositeError) Error() string
Error conforms to the built-in interface type for representing an error condition over a composed set of errors.
func (*CompositeError) Initialise ¶
func (ce *CompositeError) Initialise(text string) *CompositeError
func (*CompositeError) MarshalJSON ¶
func (ce *CompositeError) MarshalJSON() ([]byte, error)
MarshalJSON conforms to the built-in interface type for encoding a composed set of errors as json string array.
func (*CompositeError) Size ¶
func (ce *CompositeError) Size() int
ColumnAndRowSize returns the number of sub-errors in a CompositeError. It counts only directly accessible sub-errors (no nesting).
func (*CompositeError) SubError ¶
func (ce *CompositeError) SubError(index int) error
SubError returns the sub-error at the given array index of a CompositeError