A - Thanks for the question! Let us look at the paragraph from the Catechism of the Catholic Church that you cited.
2485 By its very nature, lying is to be condemned. It is a profanation of speech, whereas the purpose of speech is to communicate known truth to others. The deliberate intention of leading a neighbor into error by saying things contrary to the truth constitutes a failure in justice and charity. The culpability is greater when the intention of deceiving entails the risk of deadly consequences for those who are led astray.We can see that a lie is when we consciously withhold the truth from someone. It can be a grave sin, depending on the situation. But, what about these situations where someone is lied to in order to bring justice? The Catechism says this:
2489 Charity and respect for the truth should dictate the response to every request for information or communication. The good and safety of others, respect for privacy, and the common good are sufficient reasons for being silent about what ought not be known or for making use of a discreet LANGUAGE. The duty to avoid scandal often commands strict discretion. No one is bound to reveal the truth to someone who does not have the right to know it.Notice the last line - we are not bound to give someone the truth, if they do not have a right to know it. So, building on these two paragraphs we can define a lie as = deliberately withholding the truth from someone who has a right to it.
One example I might give to illustrate this definition is the following:
-During World War II a Christian family helps their Jewish neighbors by hiding them in their house. Nazi soldiers come knocking on the door and ask if there are Jews inside. The Christians say there are not Jews inside. Did they lie? Not by the definition above, because the Nazis have no right to the truth.
In the same way, if someone is trolling the internet looking for minors to prey upon, they have no right to know if they are talking to a police officer or not. Therefore the officer is not lying and no sin is committed.
Other situations that may keep us from giving out information (when we might say nothing at all) include protecting another person's privacy, company secrets, government intelligence, personal reputation, etc.
I hope this helps.