a blog about things that I've been thinking hard about

God's Perfect Exception

16 January, 2007
Genesis (Java version)

On the first day, God created the perfect exception ...

Day 1

On the first day, God created the perfect exception. It had an error message to explain what went wrong, and it came with a stack trace which showed exactly where it was thrown. God saw that it was good and He was very pleased with it. And that was the first day.

Day 2

And on the second day a programmer who was working on a different part of the application wrote a try-catch block which caught God's exception and ignored it, so that the application could continue running. And that was the second day.

Day 3

And on the third day God saw that His exception had been swallowed and He was angry. He wrote a call to the logging system in the constructor of his exception so that even if another programmer wrote a try-catch block to swallow His exception, it would still be logged. And that was the third day.

Day 4

And on the fourth day the programmer who was working on a different part of the application reconfigured the logging system so that God's exception was logged to a different file and the stack trace wasn't logged at all. And that was the fourth day.

Day 5

And on the fifth day God saw that the logging system had been reconfigured and unless He read the configuration options very carefully He couldn't even tell if His exception had been thrown or not, because it was so hard to work out which file if any it was being logged to. This made him so angry that He wrote a printStackTrace() call in the constructor of His exception so that even if another programmer reconfigured the logging system, God could still see His error output. And that was the fifth day.

Day 6

And on the sixth day the programmer who was working on a different part of the application reconfigured the logging system to trap System.err and System.out and redirect them to a logging handler, which, due to a spelling mistake, wasn't actually configured. And that was the sixth day.

Day 7

And on the seventh day God saw that even His printStackTrace() call had been swallowed and He called out in anger "Who keeps swallowing all my error messages?", and the heavens rent asunder and a darkness descended upon the Earth. The programming team leader told God that if perhaps there was a problem he could arrange a code review next Friday. But God spake not a reply to this suggestion, and instead He quit programming and signed up for a community college course in beetle design, which was something He had always been interested in. And that was the seventh day.

Vote for or comment on this article on Reddit or Hacker News ...