/** * Dispatch the request to the dispatcher, catching any errors which bubble up * to the surface and, in that event, display a nice template describing the error * with debugging information. This method also controls the displaying of debug * information in every request. */ public function dispatch() { try { Primitus::startTimer('request'); parent::dispatch(); $request_time = number_format(Primitus::stopTimer('request'), 2); if (defined("Primitus_DEBUG") && Primitus_DEBUG) { $engine = new Primitus_View_Engine(); $debugInfo = Primitus::generateDebuggingData(); $engine->assign("debug", $debugInfo); $engine->display("_main/debug.tpl"); } } catch (Exception $e) { $originalError = $e; try { $engine = new Primitus_View_Engine(); $engine->assign('error', $originalError); $engine->display("_main/error.tpl"); } catch (Exception $e) { $msg = "{$originalError->getMessage()} (Additionally, there was an error in the error handler: {$e->getMessage()})"; print $e->getTraceAsString(); $this->_printUglyMessage($msg); die; } } }