/** * Handles default exception if it wasn't handled before * * @param Exception $e exception to be handled * @return void * @static */ private function handleDefaultException($e) { Log::out(get_class($e) . ', ' . $e->getMessage(), Log::LEVEL_CRIT); if (php_sapi_name() == 'cli') { print "\n" . get_class($e) . " occured\n" . 'Message: ' . $e->getMessage() . "\n" . 'Code: ' . $e->getCode() . "\n" . $e->getTraceAsString() . "\n"; } else { if ($e instanceof BakedCarrotNotFoundException) { if (!headers_sent()) { header('HTTP/1.0 404 Not Found'); } if (Request::isAjax() || Request::isFlash()) { print $e->getMessage(); } else { print '<html><head></head><body style="font: 10pt arial; margin: 40px;">' . '<h1 style="font-weight: normal; font-size: 30px;">404 Page Not Found</h1>' . ($e->getMessage() ? '<h3 style="margin: 0; font-weight: normal;">Message: ' . $e->getMessage() . '</h3>' : '') . (self::isDevMode() ? '<p>' . nl2br($e->getTraceAsString()) . '</p>' : '') . '</body>'; } } else { if (!headers_sent()) { header('HTTP/1.1 500 Internal Server Error'); } if (Request::isAjax() || Request::isFlash()) { print 'EXCEPTION (' . get_class($e) . '): ' . $e->getMessage() . "\n"; if (self::isDevMode() && get_class($e) == 'PDOException') { print 'SQL: ' . Db::lastSql(); } } else { print '<html><head></head><body style="font: 10pt arial; margin: 40px;">' . '<h1 style="font-weight: normal; font-size: 30px;">' . get_class($e) . ' occured</h1>' . '<h3 style="margin: 0; font-weight: normal;">Message: ' . $e->getMessage() . '</h3>' . '<h3 style="margin: 0; font-weight: normal;">Code: ' . $e->getCode() . '</h3>' . (self::isDevMode() && get_class($e) == 'PDOException' ? '<h3 style="margin: 0;">SQL: ' . Db::lastSql() . '</h3>' : '') . (self::isDevMode() ? '<p>' . nl2br($e->getTraceAsString()) . '</p>' : '') . '<h4 style="font-weight: normal;"><em>Baked Carrot ver ' . BAKEDCARROT_VERSION . '</em></h4>' . '</body>'; } } } exit(-1); }