It’s detraction if it’s true and hurts another person’s reputation without a proportionate reason. Most of the old-time moralists said that the general rule is this: If a serious sin is revealed, it’s a serious sin of detraction. But the circumstances can mitigate or worsen the sin.
The faithful and holy Jesuit, Fr. John Hardon, wrote this in his catechism (1975 ed.), which represents the gentlest position I know of:
The seriousness of the sin committed will mainly derive from the gravity of the fault or limitation disclosed. But it will also depend on the dignity of the person detracted and the harm done to him and others by revealing something that is hidden and whose disclosure lowers (if it does not ruin) his standing in the public eye. …
When the revelation of another person’s fault is necessary or very useful, as in defense of self or of others, no injustice is done in revealing it. This would be the case when the failing or defect is made known to parents, or superiors, or for the purpose of seeking counsel or help, or to prevent harm to others, though again, there must be adequate proportion between the lessening of a person’s reputation (which is not intended) and the good to be achieved by the disclosure (which is intended). This would cover such contingencies such as anticipating unjust harm to oneself in the law courts, or even seeking consolation of a trusted friend by revealing the injustice done.
The Catholic Catechism: A Contemporary Catechism of the Teachings of the Catholic Church, p. 409
Pray for Fr. Hardon’s canonization!