# README
pkg说明
errors
此包主要作用是聚合errors,将多个不同的error聚合成一个error。如果是同样的error则只会被记录一次。 使用方式如下所示:
func closeClients(rdclis []*redis.Client) error {
var errlist []error
for _, rdcli := range rdclis {
if rdcli != nil {
err := rdcli.Close()
if err != nil {
errlist = append(errlist, err)
}
}
}
return utilerrors.NewAggregate(errlist)
}
# Functions
AggregateGoroutines runs the provided functions in parallel, stuffing all non-nil errors into the returned Aggregate.
BadRequest generates a 400 error.
Conflict generates a 409 error.
ConvertGrpcCode converts a standard Go error into its canonical code.
CreateAggregateFromMessageCountMap converts MessageCountMap Aggregate.
FilterOut removes all errors that match any of the matchers from the input error.
Flatten takes an Aggregate, which may hold other Aggregates in arbitrary nesting, and flattens them all into a single Aggregate, recursively.
Forbidden generates a 403 error.
No description provided by the author
No description provided by the author
InternalServerError generates a 500 error.
MethodNotAllowed generates a 405 error.
New generates a custom error.
NewAggregate converts a slice of errors into an Aggregate interface, which is itself an implementation of the error interface.
NotFound generates a 404 error.
Parse tries to parse a JSON string into an error.
Reduce will return err or, if err is an Aggregate and only has one item, the first item in the aggregate.
Timeout generates a 408 error.
Unauthorized generates a 401 error.
UnwrapIgnorableError tries to parse a JSON string into an error.
IgnoreError generates a -1 error.
# Variables
ErrPreconditionViolated is returned when the precondition is violated.
# Interfaces
Aggregate represents an object that contains multiple errors, but does not necessarily have singular semantic meaning.
# Type aliases
Matcher is used to match errors.
TODO: move this errors to tech-lab/utils MessageCountMap contains occurrence for each error message.