As strange as it may sound, but the error was because in one of the posts I had published , there was – at end!!
So I deleted the posts as that looked like the problem.
Then I restored them one of one and tried to find out what was the problem.
Not sure why that caused the exception to be thrown. Maybe because I was using two shortcodes in the posts abase mysql and table2chart.
Bottom line, do not fiddle with wordpress core files