/** * Provides a nice print out of the stack trace when an exception is thrown. * * @param Exception $e Exception object. */ function framework_exception_handler($e) { if (!DEBUG) { page_not_found(); } echo '<style>h1,h2,h3,p,td {font-family:Verdana; font-weight:lighter;}</style>'; echo '<p>Uncaught ' . get_class($e) . '</p>'; echo '<h1>' . $e->getMessage() . '</h1>'; $traces = $e->getTrace(); if (count($traces) > 1) { echo '<p><b>Trace in execution order:</b></p>' . '<pre style="font-family:Verdana; line-height: 20px">'; $level = 0; foreach (array_reverse($traces) as $trace) { ++$level; if (isset($trace['class'])) { echo $trace['class'] . '→'; } $args = array(); if (!empty($trace['args'])) { foreach ($trace['args'] as $arg) { if (is_null($arg)) { $args[] = 'null'; } else { if (is_array($arg)) { $args[] = 'array[' . sizeof($arg) . ']'; } else { if (is_object($arg)) { $args[] = get_class($arg) . ' Object'; } else { if (is_bool($arg)) { $args[] = $arg ? 'true' : 'false'; } else { if (is_int($arg)) { $args[] = $arg; } else { $arg = htmlspecialchars(substr($arg, 0, 64)); if (strlen($arg) >= 64) { $arg .= '...'; } $args[] = "'" . $arg . "'"; } } } } } } } echo '<b>' . $trace['function'] . '</b>(' . implode(', ', $args) . ') '; echo 'on line <code>' . (isset($trace['line']) ? $trace['line'] : 'unknown') . '</code> '; echo 'in <code>' . (isset($trace['file']) ? $trace['file'] : 'unknown') . "</code>\n"; echo str_repeat(" ", $level); } echo '</pre>'; } echo "<p>Exception was thrown on line <code>" . $e->getLine() . "</code> in <code>" . $e->getFile() . "</code></p>"; $dispatcher_status = Dispatcher::getStatus(); $dispatcher_status['request method'] = get_request_method(); debug_table($dispatcher_status, 'Dispatcher status'); if (!empty($_GET)) { debug_table($_GET, 'GET'); } if (!empty($_POST)) { debug_table($_POST, 'POST'); } if (!empty($_COOKIE)) { debug_table($_COOKIE, 'COOKIE'); } debug_table($_SERVER, 'SERVER'); }
<html> <head> <title>404 Not Found</title> </head> <body> <h1>Not Found</h1> <p>The requested URL <?php echo Dispatcher::getStatus('requested_url'); ?> was not found on this server.</p> <hr/> <address>KISS 'Keep It Simple, Stupid'</address> </body> </html> <!-- - Unfortunately, Microsoft has added a clever new 'feature' to Internet Explorer. - If the text of an error's message is 'too small', specifically less than 512 bytes, - Internet Explorer returns its own error message. You can turn that off, but it's - pretty tricky to find switch called 'smart error messages'. That means, of course, - that short error messages are censored by default. - - The workaround is pretty simple: pad the error message with a big comment like this - to push it over the five hundred and twelve bytes minimum. Of course, that's exactly - what you're reading right now. -->