Lying when asked about a secret

Q 2: Is it permissible to lie in the following situation or not: If someone asks you about something personal and secret; some forbidden thing that I committed while being alone, but no one saw me doing it other than Allah who covered it, is it obligatory to tell the truth and expose ourselves or should we lie? What if this person asks me to swear by Allah that I have not done this?

A: It is not permissible to lie, except in the situations that the Prophet (peace be upon him) made exceptions. They are lying to reconcile people, lying during a war, and lying between spouses to maintain their married life. It is obligatory for anyone who commits a sin to make Tawbah (repentance to Allah) and not mention it to anyone, unless it involves someone’s right that was usurped or violated. In this case, the sin must be confessed to them and their right returned to them, if it is material; or their forgiveness sought for other than that.May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.