Ganesha certainly has a sweet tooth!
On one of his birthdays, he was visiting households, accepting offerings of sweet puddings. Having eaten a good number of these, he set out moving on his mouse at night.
Suddenly the mouse stumbled -- it had seen a snake and panicked -- and Ganesha fell down. His stomach burst open and all the sweet puddings came out. But Ganesh stuffed them back into his stomach. Then he caught hold of the snake and tied it around his belly like a belt!
The moon had a hearty a laugh at the incident. An angry Ganapati pulled out one of his tusks and hurled it at the moon. He also cursed that no one should look at the moon on Ganesha Chathruthi. If anyone did, s/he would be cursed with ill repute, he declared.
However, if someone gazed at the moon by mistake, the only way s/he can be freed from the curse is by repeating or listening to the story of how Lord Krishna cleared his character regarding the Syamantaka Jewel. This story is quoted in a holy book, the Shrimad Bhagwatwam.
Also See: Timeless Ganesha