Truth in the hierarchy of values
Is truth a supreme value ? That's to say, in any situation for action does the requirement to tell the truth override necessarily all other values, including that of avoiding pain and harm ?
Some situations for action are truth-oriented : giving evidence as a witness in a trial, for instance, or if you are religiously-minded confessing to a priest. Unless you tell the truth, or as much of it as is relevant or in good conscience appears to you to be relevant, you have perverted the situation.
These are only examples, not a complete enumeration. But in all other situations for action truth (or veracity) is only one value among others. It has no automatic moral priority.
Truth and the casual inquirer
I do not have an obligation to tell the truth to someone who is not entitled to know it - no casual inquirer is entitled to know the truth about my sexual orientation, whether I have been married, whether I have children, whether I have been made redundant, or whether I drink alcohol. In certain other situations I may have a duty to tell the truth about all these things, but not to just anyone who chooses to ask.
Economy of truth
Even when I have an obligation to tell nothing but the truth, there may be no obligation to tell the whole truth (relevant to a situation). I may have an obligation to tell a friend that I have cancer - without having an obligation to reveal the full extent of my condition. I may terminate the conversation after I have disclosed the fact that I have cancer. Thus I tell nothing but the truth but do not tell the whole truth. I have and exercise a right of privacy at this point.
Truth and harm
In other cases, when telling the truth would cause harm without any compensating advantage, then equally I do not have an obligation to tell the truth. Such a case might be one of withholding the truth from a dying patient whose distress would increase without benefit to anyone, even and especially her- or himself, if I were to tell them the truth about their situation. 'Truth is never harmful' is plainly untrue. With a different patient, respect for persons might on the contrary require me to tell the truth. Context is a vital consideration.
Your main concern appears to be cases where truth-telling produces useless or dangerous harm. In all situations other than those which are truth-oriented, truth needs to be balanced against harm and against other values. I can't see how one could devise any kind of algorithm for this : telling someone the unpleasant truth might be worth the harm it would cause. If you tell me I have a soup stain on my tie when I am about to give a speech, I suffer the harm of embarrassment and alarm but I really would prefer that to not knowing the truth about the stain.
The judgement between truth and harm, in non-truth-oriented situations, is contextual and the only rule I can (tentatively) offer is : all else equal, there is no obligation to tell the truth, and sufficient reason not to tell the truth, when veracity would cause harm without compensating advantage. All else would not be equal in the respect for persons case.
Limitations of an ethics of rules
I don't think any rule or set of rules can be applied here - or elsewhere in ethics. My own tentative rule had to carry an 'all else equal' clause which defeated its status as a rule strictly speaking. Virtue ethics, which involves a character disposition, responsive and adjustable to the exact circumstances of a situation, appears for this reason preferable to a rules-based ethics.
Sissela Bok, Lying: Moral Choice in Public and Private Life, Published by Vintage (1978)
ISBN 10: 0679724702 ISBN 13: 9780679724704
Jennifer Mather Saul, Lying, Misleading, and What is Said: An Exploration in Philosophy of Language and in Ethics, Published by Oxford University Press, United Kingdom, 2015SBN 10: 0198744110 / ISBN 13: 9780198744115.
Guy Axtell and Philip Olson, 'Recent Work in Applied Virtue Ethics', American Philosophical Quarterly, Vol. 49, No. 3 (JULY 2012), pp. 183-203.