You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: errors.go
    path of file: ./repos/prisma-client-go/runtime/types
    
    the code of the file until where you have to start completion: package types

import (
	"errors"

	"github.com/steebchen/prisma-client-go/engine/protocol"
)

// ErrNotFound gets returned when a database record does not exist
var ErrNotFound = errors.New("ErrNotFound")

// IsErr
    
func CheckUniqueConstraint[T F](err error) (*ErrUniqueConstraint[T], bool) {
	if err == nil {
		return nil, false
	}

	var ufr *protocol.UserFacingError
	if ok := errors.As(err, &ufr); !ok {
		return nil, false
	}

	if ufr.ErrorCode != "P2002" {
		return nil, false
	}

	// postgres
	if items, ok := ufr.Meta.Target.([]interface{}); ok {
		var fields []T
		for _, f := range items {
			field, ok := f.(string)
			if ok {
				fields = append(fields, T(field))
			}
		}
		return &ErrUniqueConstraint[T]{
			Fields: fields,
		}, true
	}

	// mysql
	if item, ok := ufr.Meta.Target.(string); ok {
		return &ErrUniqueConstraint[T]{
			Key: item,
		}, true
	}

	return nil, false
}