github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/pkg/spiceerrors/util.go (about)

     1  package spiceerrors
     2  
     3  import (
     4  	"maps"
     5  )
     6  
     7  type WithMetadata interface {
     8  	DetailsMetadata() map[string]string
     9  }
    10  
    11  // CombineMetadata combines the metadata found on an existing error with that given.
    12  func CombineMetadata(withMetadata WithMetadata, metadata map[string]string) map[string]string {
    13  	clone := maps.Clone(withMetadata.DetailsMetadata())
    14  	for key, value := range metadata {
    15  		clone[key] = value
    16  	}
    17  	return clone
    18  }