func (h *handler) Handle(err error) {
	var ctx map[string]interface{}
	if kvs := emperror.Context(err); len(kvs) > 0 {
		ctx = ToMap(kvs)
	}
	logger := h.logger.WithFields(log.Fields(ctx))
	type errorCollection interface {
		Errors() []error
	}
	if errs, ok := err.(errorCollection); ok {
		for _, e := range errs.Errors() {
			ctx = nil
			if kvs := emperror.Context(e); len(kvs) > 0 {
				ctx = ToMap(kvs)
			}
			h.logger.WithFields(log.Fields(ctx)).Error(e.Error())
		}
	} else {
		logger.Error(err.Error())
	}
}
Handle logs an error
package errors
import (
	"github.com/goph/emperror"
	"github.com/banzaicloud/hollowtrees/internal/platform/log"
)
type handler struct {
	logger log.Logger
}
func NewHandler(logger log.Logger) *handler {
	return &handler{logger: logger}
}