func (p Path) NewError(err error) error {
	perr, wrappingPath := err.(PathError)
	pathLen := len(p)
	if wrappingPath {
		pathLen = pathLen + len(perr.Path)
	}
	sPath := make(Path, pathLen)
	copy(sPath, p)
	if wrappingPath {
		copy(sPath[len(p):], perr.Path)
	}
	return PathError{
		error: err,
		Path:  sPath,
	}
}
NewError creates a new PathError for the current path, wrapping the given
error.
package cty
import (
	"fmt"
)
type PathError struct {
	error
	Path Path
}
func errorf(path Path, f string, args ...interface{}) error {
	sPath := make(Path, len(path))
	copy(sPath, path)
	return PathError{
		error: fmt.Errorf(f, args...),
		Path:  sPath,
	}
}
func (p Path) NewErrorf(f string, args ...interface{}) error {
	return errorf(p, f, args...)
}