Ali ibn Abu Talib narrated that he heard the Prophet(SAWS) say: “I never resolved to do any bad things that the people of ignorance would resolve to do, except on two occasions in life; and on both occasions, Allah protected me from perpetrating those bad things. One night, I was north of Makkah in the company of a young man from the Quraish; we were with his family’s sheep, which he was herding, when I said to him, ‘Watch over my sheep, so that I can while away this evening with conversation and entertainment in Makkah, just as other youth while away their evenings with conversation and entertainment.’ He said, ‘Yes’, and so I set out. When I reached the nearest house from the houses of Makkah, I heard singing, the striking of Dufoof, and (the sound of) pipes. I asked,’What is this?’ They said,’Such and such man married such and such woman.’ It was a man from the Quraish who had married a woman from the Quraish. And so I amused myself with that singing and with those sounds until sleep overcame me, and then the only thing that woke me up was the heat of the sun, and so I returned. He (i.e., the other shepherd) asked, ‘What did you do?’ I informed him (about what had happened). Then I made a asimilar request to him on another night, and he agreed. I set out, and I heard sounds that were similar and words similar to what was spoken to me (on the earlier night) were spoken to me (again). I amused myself with what I heard, until sleep overcame my eyes. And it was only the touching of the sun that awoke me. Then I returned to my companion, who said, ‘What did you do?’ I said, ‘I didn’t do anything.’ By Allah, after that, I never again resolved to perpetrate the evil that the people of ignorance would perpetrate. I continued upon that (protected state) until Allah honoured me by making me His Prophet.”
Saheeh As-Seerah An-Nabawiyyah, Ibraheem Al Ali, Pg. 57.