示例#1
0
文件: Error.php 项目: aquarion/Plank
    function defaultError($status, $message, $response)
    {
        $trace = debug_backtrace();
        if (is_object($message) && is_subclass_of($message, 'Exception')) {
            $trace = $message->getTrace();
            $message = $message->getMessage();
        }
        if (defined('DESTRUCT')) {
            die($message);
        }
        $view = new Plank_View('Errors', 'Error503');
        $view->error = '		
		<p>Something\'s drastically wrong. Sorry about this, this is a last-ditch fail message, caused by terror upon terror to have been inflicted upon my poor innocent paradiems. Nothing\'s worked. The thing you asked for? Failed. The recovery from error system? Broken. The error display system itself? F****d. I have no idea what to try next, so I\'m going to throw data at you until you go away.</p>
				
		<h2>' . $message . '</h2>
		
		';
        $view->error .= Plank_Error::getBacktrace($trace);
        $response->setContent($view->render());
        $response->respond();
        if (defined("TEXTMODE")) {
            echo "Uh-Oh\n";
            echo striptags($view->error);
            die;
        } else {
            echo Plank_Logger_Display::display();
        }
    }
示例#2
0
文件: Plank.php 项目: aquarion/Plank
set_exception_handler("__exception_handler");
function __autoload($class_name)
{
    Plank_Autoload::loadClass($class_name);
}
$request = new Plank_HTTP_Request();
$response = new Plank_HTTP_Response();
function handle_exceptions($e)
{
    global $response;
    Plank_Error::Error503($e, $response);
}
set_exception_handler("handle_exceptions");
try {
    Plank_Logger::log('Init', 'Hello World', L_INFO);
    Plank_Logger::logStat('Init', 'Hello World');
    Plank_Config::getInstance();
    define('INIT', time());
    Plank_Logger::logStat('Init', 'Finished init');
    new Plank_Site($request, &$response);
    Plank_Logger::logStat('Init', 'Finished MVC');
} catch (Plank_Exception_NotFound $e) {
    Plank_Error::Error404($e->getMessage(), $response);
    #} catch ( Exception $e ){
    #	Plank_Error::Error503($e, $response);
}
$response->respond();
Plank_Logger::logStat('Init', 'Goodbye, Cruel World');
Plank_Logger::log('Init', 'Memory Use: ' . number_format(memory_get_usage()), L_INFO);
echo Plank_Logger_Display::display();
define('DESTRUCT', true);