Exemplo n.º 1
0
func getInnerKV(err error) KV {
	kvi := errctx.Get(err, errKV)
	if kvi == nil {
		return KV{}
	}
	return kvi.(KV)
}
Exemplo n.º 2
0
// ErrWithKV embeds a KV into an error, returning a new error instance. If the
// error already has a KV embedded in it then the returned error will have a
// the merging of the two.
func ErrWithKV(err error, kv KV) error {
	if err == nil {
		return nil
	}
	existingKV := errctx.Get(err, errKV)
	if existingKV != nil {
		kv = Merge(existingKV.(KV), kv)
	}
	return errctx.Set(err, errKV, kv)
}