Documentation
¶
Overview ¶
Package ayderr is the set of error types in Ayd.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AydError ¶
type AydError struct {
// contains filtered or unexported fields
}
AydError is the error type of Ayd.
Please use errors.Is or errors.Unwrap if you want to know what kind of error is it.
type List ¶
type List struct {
// What is the error that describes what kind of errors is this.
What error
// Children is the detail errors in this error list.
Children []error
}
List is a list of errors.
type ListBuilder ¶
ListBuilder is the List builder.
Example ¶
package main
import (
"errors"
"fmt"
"github.com/macrat/ayd/internal/ayderr"
)
func main() {
// make a base error.
ErrSomething := errors.New("something wrong")
// prepare builder with base error.
e := &ayderr.ListBuilder{What: ErrSomething}
// e.Build() returns nil because builder has no child error yet.
fmt.Println("--- before push errors ---")
fmt.Println(e.Build())
fmt.Println()
// push errors as children.
e.Push(errors.New("A is wrong"), errors.New("B is wrong"))
// or generate error and push as a child.
e.Pushf("%s is also wrong", "C")
// e.Build() returns List now, because it has children.
fmt.Println("--- after push errors ---")
fmt.Println(e.Build())
}
Output: --- before push errors --- <nil> --- after push errors --- something wrong: A is wrong B is wrong C is also wrong
func (*ListBuilder) Build ¶
func (lb *ListBuilder) Build() error
Build creates List if it has any child. It returns nil if there is no child.
func (*ListBuilder) Push ¶
func (lb *ListBuilder) Push(err ...error)
Push appends a error as a child.
func (*ListBuilder) Pushf ¶
func (lb *ListBuilder) Pushf(format string, values ...interface{})
Pushf calls fmt.Errorf and then push as a child of this list.
Click to show internal directories.
Click to hide internal directories.