public function onError(GetResponseForExceptionEvent $event) { if (!$this->enabled) { return; } $handler = new DebugExceptionHandler($this->debug); $event->setResponse($handler->createResponse($event->getException())); }
/** * Renders the exception panel stylesheet for the given token. * * @param string $token The profiler token * * @return Response A Response instance */ public function cssAction($token) { $this->profiler->disable(); $exception = $this->profiler->loadProfile($token)->getCollector('exception')->getException(); $template = $this->getTemplate(); if (!$this->templateExists($template)) { $handler = new ExceptionHandler(); return new Response($handler->getStylesheet($exception)); } return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig')); }
/** * Renders the exception panel stylesheet for the given token. * * @param string $token The profiler token * * @return Response A Response instance */ public function cssAction($token) { if (null === $this->profiler) { throw new NotFoundHttpException('The profiler must be enabled.'); } $this->profiler->disable(); $exception = $this->profiler->loadProfile($token)->getCollector('exception')->getException(); $template = $this->getTemplate(); if (!$this->templateExists($template)) { $handler = new ExceptionHandler(); return new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css')); } return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css')); }
/** * @param Request $request * @param FlattenException $exception * @param string $format */ public function showAction(Request $request, FlattenException $exception, $format) { $handler = new ExceptionHandler($this->app['debug']); if ($this->app['debug']) { return $handler->createResponse($exception); } $code = $exception->getStatusCode(); $template = $this->resolve($request, $code, $format); if ($template) { $contents = $this->app['twig']->render($template, array('status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception)); return new Response($contents, $code); } return $handler->createResponse($exception); }
public function init() { if ($this->debug) { ini_set('display_errors', 1); error_reporting(-1); DebugUniversalClassLoader::enable(); ErrorHandler::register(); ExceptionHandler::register(); } else { ini_set('display_errors', 0); } }
public function init() { if ($this->debug) { ini_set('display_errors', 1); error_reporting(-1); DebugClassLoader::enable(); ErrorHandler::register($this->errorReportingLevel); if ('cli' !== php_sapi_name()) { ExceptionHandler::register(); } } else { ini_set('display_errors', 0); } }
function handle(\Exception $exception) { if ($this->app) { try { $exception = $this->app->hook('app.exception', $this, $exception); } catch (\Exception $innerEx) { return $this->_handleNested($exception, $innerEx); } } if ($exception) { if ($this->app && !$this->app->core->debug) { try { $code = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : 500; $response = new Response\FancyResponse(new Request\StaticRequest($this->app), array('code' => $code, 'title' => SymfonyResponse::$statusTexts[$code], 'exception' => $exception), 'error.html.twig'); $response->statusCode = $code; $response->send(); return; } catch (\Exception $innerEx) { return $this->_handleNested($exception, $innerEx); } } parent::handle($exception); } }
<?php use Symfony\Component\HttpKernel\Debug\ErrorHandler; use Symfony\Component\HttpKernel\Debug\ExceptionHandler; require_once __DIR__ . '/../vendor/autoload.php'; error_reporting(-1); ErrorHandler::register(); if ('cli' !== php_sapi_name()) { ExceptionHandler::register(); } $app = (require __DIR__ . '/../src/bootstrap.php'); require __DIR__ . '/../src/controllers.php'; $app['debug'] = true; $app->run();
public function testNestedExceptions() { $handler = new ExceptionHandler(true); $response = $handler->createResponse(new \RuntimeException('Foo', null, new \RuntimeException('Bar'))); }
public function init() { ini_set('display_errors', 0); if ($this->debug) { error_reporting(-1); if (class_exists('Symfony\\Component\\ClassLoader\\DebugClassLoader')) { DebugClassLoader::enable(); } ErrorHandler::register($this->errorReportingLevel); if ('cli' !== php_sapi_name()) { ExceptionHandler::register(); } else { ini_set('display_errors', 1); } } }
public function onSilexError(GetResponseForErrorEvent $event) { $app = $event->getKernel(); $handler = new DebugExceptionHandler($app['debug']); $event->setResponse($handler->createResponse($event->getException())); }