Freedom from Error

It has always been my understanding that the faithful have a right to be protected from error. For example back in the Middle Ages heresy was not only a canonical but also a civil offense because it endangered the faith of the populace and therefore violated people’s right to not have their faith endangered. Is there any Church document that clearly expresses this teaching? I know the motto “error has no rights” is common but I am hoping to be pointed towards some magisterial texts on the matter. Thanks!

DISCLAIMER: The views and opinions expressed in these forums do not necessarily reflect those of Catholic Answers. For official apologetics resources please visit www.catholic.com.