/** * Show exception screen * * @param \Exception $exception */ public function showException(\Exception $exception) { @ob_end_clean(); $msg = sprintf("%s\nFile: %s\nLine: %d\nTrace:\n%s", $exception->getMessage(), $exception->getFile(), $exception->getLine(), $exception->getTraceAsString()); \Kalibri::logger()->add(Logger::L_EXCEPTION, $msg); $viewName = \Kalibri::config()->get('error.view.exception'); if ($viewName) { $view = new \Kalibri\View($viewName); $view->ex = $exception; $str = ''; $file = \fopen($exception->getFile(), 'r'); for ($i = 0; $i < $exception->getLine() - 16; $i++) { \fgets($file); } for ($i = 0; $i < 20; $i++) { $str .= \fgets($file); } $view->code = Highlight::php($str, true, 1, $exception->getLine()); if ($view->isExists()) { $view->render(); } else { // Fallback to show any message in case if exception view not found or not set echo "<h1>Exception</h1><p>{$exception->getMessage()}</p>"; } } exit; }
public static function getPanel() { $view = new \Kalibri\View('Debug/panel'); $view->marks = \Kalibri::benchmark()->getMarks(true); return $view->render(true); }