Trying to catch a missing stack frame

Yesterday, while doing some work on a Drupal 7 site, I ran across the PHP error:

Fatal error: Exception thrown without a stack frame in Unknown on line 0

At first this seemed like the worst error message I could possibly receive. Not knowing where to start I did some research and ran across a blog article suggesting that I wrap the entirety of index.php in a try / catch block.

<?php
try {

// Contents of index.php.

} catch (Exception $e) {

print_r(var_dump($e));
}
// End of index.php.

This worked! And I was able to get the entire stack trace from the caught exception. It turned out that I had a mySQL 2006 error, because my max_allowed_packet size was too low.