Generally speaking, your sentence is right according to the grammar. Bcz, " 的时候"="when"(in a statement,not a question), so you can say anything as you like. This sentence is not the real Chinese way although there is no mistake, because you didn't give us your content or any hint, just a sentence only the grammar is a bit strange, so we have to use the whole sentence structure like"Subject + Verb + Object" is our Chinese way, as a result, all of the people who correct you add an object for the verb "吃", like "吃饭" "吃东西"etc. hope will help you more or less.