When discerning doctrine, whether one regarding the confessing/sharing of our sins/struggles or anything else, we must apply not just all the Scriptures regarding it, but also the attributes of God, the overview of our present dispensation and plan of God ("Christ in us, the hope of glory"), etc., etc.
In short, we should as NT believers be led by the Spirit in all we do, including when and to whom and to what degree we share of our lives.
If someone's heart is not prepared to hear what we're wanting to say, then our words will bring death to them, and it will be OUR fault. We will have caused a brother or sister to stumble, and even though it was the impurity of THEIR heart whereby they fell, it is accounted TO US as sin (Romans, I Cor.).
In Romans 2 we read how when we judge another, we ourselves are guilty of that sin. It is because the sin we see or suppose to see in them, is also in our own heart. If it were not, their sin or alleged sin would not occur to us, it would not cross our mind (intellectualism scoffs at this).
So, yes, when we confess a sin to another, if the listener's heart is not sufficiently purified, yes of course they will often condemnably judge us. And if they are suppressing in their heart the same sin by some work of the flesh, look out, for then "envy and strife" (KJV) will likely take them over, and....
We must be led by the S(s)pirit in all we do, a main reason why God put it into us.