Abu Hurairah (May Allah be pleased with him) reported: Messenger of Allah (PBUH) said, "Every one of my followers will be forgiven except those who expose (openly) their wrongdoings. An example of this is that of a man who commits a sin at night which Allah has covered for him, and in the morning, he would say (to people): I committed such and such sin last night, while Allah had kept it a secret. During the night Allah has covered it up but in the morning he tears up the cover provided by Allah Himself."[Al-Bukhari and Muslim].
We learn from this Hadith that commission of a sin due to human frailties on which one is ashamed but does not like to express is something which might hopefully be forgiven by Allah. In fact, its remission after penitence is almost sure. But to commit a sin openly is totally different because, firstly, the heart of such a person is deprived of the fear of Allah. Secondly, he has no respect and regard for Divine injunctions. Thirdly, such a person usually does not repent his sins. Fourthly, he makes a declaration of breach of Divine injunctions which amounts to inviting His wrath and punishment.