Codebase list golang-github-go-kit-kit / 0fadbe9
Introduce ErrorHandlerFunc (#915) Marat Reymers authored 3 years ago Peter Bourgon committed 3 years ago
1 changed file(s) with 11 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
2525 func (h *LogErrorHandler) Handle(ctx context.Context, err error) {
2626 h.logger.Log("err", err)
2727 }
28
29 // The ErrorHandlerFunc type is an adapter to allow the use of
30 // ordinary function as ErrorHandler. If f is a function
31 // with the appropriate signature, ErrorHandlerFunc(f) is a
32 // ErrorHandler that calls f.
33 type ErrorHandlerFunc func(ctx context.Context, err error)
34
35 // Handle calls f(ctx, err).
36 func (f ErrorHandlerFunc) Handle(ctx context.Context, err error) {
37 f(ctx, err)
38 }