/** * Permite mostrar un excepción propia. * * @param string $type * @param string $message * @return void */ private static function viewException($type, $message) { $template = 'exception'; $title = 'Excepción'; // 1 es Error if ($type === 1) { $title = 'Error'; } if (Settings::getInstance()->inDebug()) { $contentBuffer = json_decode(ob_get_contents()); // Limpio el buffer de salida previo if (ob_get_length()) { ob_clean(); } Context::useGlobal(false); Context::set('exception', $title); Context::set('details', $message); $response = new Response(); if (is_array($contentBuffer)) { $contentBuffer['ForeverPHPException'] = Context::all(); $response->json($contentBuffer)->make(); } else { // Si hay buffer de salida previo cambio el template if (ob_get_length() != 0) { $template = 'exception-block'; } // Le indico a la vista que haga render usando los templates del framework Settings::getInstance()->set('ForeverPHPTemplate', true); $response->render($template)->make(); } } else { // Termino el buffer de salida y lo limpio ob_end_clean(); // Redirijo a un error 500 return Redirect::error(500); } }