当前位置: 首页>>代码示例>>PHP>>正文


PHP Debug\ExceptionHandler类代码示例

本文整理汇总了PHP中Symfony\Component\Debug\ExceptionHandler的典型用法代码示例。如果您正苦于以下问题:PHP ExceptionHandler类的具体用法?PHP ExceptionHandler怎么用?PHP ExceptionHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ExceptionHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendException

 public function sendException($exception)
 {
     if (!$this->isErrorFromBot()) {
         $recipients = Config::get("error-emailer::to");
         if (isset($recipients['address'])) {
             // this is a single recipient
             if ($recipients['address']) {
                 $recipients = array($recipients);
             } else {
                 $recipients = array();
             }
         }
         if (sizeof($recipients) > 0) {
             if ($exception instanceof FlattenException) {
                 $flattened = $exception;
             } else {
                 $flattened = FlattenException::create($exception);
             }
             $handler = new ExceptionHandler();
             $content = $handler->getContent($flattened);
             $model = array('trace' => $content, 'exception' => $exception, 'flattened' => $flattened);
             Mail::send(Config::get("error-emailer::error_template"), $model, function ($message) use($model, $recipients) {
                 $subject = View::make(Config::get("error-emailer::subject_template"), $model)->render();
                 $message->subject($subject);
                 foreach ($recipients as $to) {
                     $message->to($to['address'], $to['name']);
                 }
             });
         }
     }
 }
开发者ID:Nuwira,项目名称:laravel-error-emailer,代码行数:31,代码来源:ErrorEmailer.php

示例2: testConfigure

 public function testConfigure()
 {
     $logger = $this->getMock('Psr\\Log\\LoggerInterface');
     $userHandler = function () {
     };
     $listener = new DebugHandlersListener($userHandler, $logger);
     $xHandler = new ExceptionHandler();
     $eHandler = new ErrorHandler();
     $eHandler->setExceptionHandler(array($xHandler, 'handle'));
     $exception = null;
     set_error_handler(array($eHandler, 'handleError'));
     set_exception_handler(array($eHandler, 'handleException'));
     try {
         $listener->configure();
     } catch (\Exception $exception) {
     }
     restore_exception_handler();
     restore_error_handler();
     if (null !== $exception) {
         throw $exception;
     }
     $this->assertSame($userHandler, $xHandler->setHandler('var_dump'));
     $loggers = $eHandler->setLoggers(array());
     $this->assertArrayHasKey(E_DEPRECATED, $loggers);
     $this->assertSame(array($logger, LogLevel::INFO), $loggers[E_DEPRECATED]);
 }
开发者ID:scrobot,项目名称:Lumen,代码行数:26,代码来源:DebugHandlersListenerTest.php

示例3: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function render($request, Exception $e)
 {
     $e = FlattenException::create($e);
     $handler = new SymfonyExceptionHandler(env('APP_DEBUG', false));
     $decorated = $this->decorate($handler->getContent($e), $handler->getStylesheet($e));
     return Response::create($decorated, $e->getStatusCode(), $e->getHeaders());
 }
开发者ID:rlacerda83,项目名称:lumen-framework,代码行数:14,代码来源:Handler.php

示例4: testNestedExceptions

 public function testNestedExceptions()
 {
     $handler = new ExceptionHandler(true);
     ob_start();
     $handler->sendPhpResponse(new \RuntimeException('Foo', 0, new \RuntimeException('Bar')));
     $response = ob_get_clean();
     $this->assertStringMatchesFormat('%A<span class="exception_message">Foo</span>%A<span class="exception_message">Bar</span>%A', $response);
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:8,代码来源:ExceptionHandlerTest.php

示例5: handleWithSymfony

 protected function handleWithSymfony(Exception $exception)
 {
     if (!$exception instanceof FlattenException) {
         $exception = FlattenException::create($exception);
     }
     $handler = new ExceptionHandler($this->debug);
     return Response::create($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders());
 }
开发者ID:autarky,项目名称:framework,代码行数:8,代码来源:DefaultErrorHandler.php

示例6: onSilexError

 public function onSilexError(GetResponseForExceptionEvent $event)
 {
     if (!$this->enabled) {
         return;
     }
     $handler = new DebugExceptionHandler($this->debug);
     $event->setResponse($handler->createResponse($event->getException()));
 }
开发者ID:ahmedibr,项目名称:project,代码行数:8,代码来源:ExceptionHandler.php

示例7: handleException

 /**
  * Convert an exception to a response
  *
  * @param \Exception $exception
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function handleException($exception)
 {
     if (!$exception instanceof FlattenException) {
         $exception = FlattenException::create($exception);
     }
     $handler = new BaseExceptionHandler($this->debug);
     $decorated = $this->decorate($handler->getContent($exception), $handler->getStylesheet($exception));
     return new Response($decorated, $exception->getStatusCode(), $exception->getHeaders());
 }
开发者ID:MikeGeorgeff,项目名称:siphon,代码行数:15,代码来源:ExceptionHandler.php

示例8: onSilexError

 public function onSilexError(GetResponseForExceptionEvent $event)
 {
     $handler = new DebugExceptionHandler($this->debug);
     $exception = $event->getException();
     if (!$exception instanceof FlattenException) {
         $exception = FlattenException::create($exception);
     }
     $response = Response::create($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset(ini_get('default_charset'));
     $event->setResponse($response);
 }
开发者ID:abdonor,项目名称:silex_simple_api,代码行数:10,代码来源:ExceptionHandler.php

示例9: __toString

 public function __toString()
 {
     try {
         return parent::__toString();
         // TODO: Change the autogenerated stub
     } catch (\Exception $exc) {
         ExceptionHelper::logException($exc);
         $eh = new ExceptionHandler(env('APP_DEBUG'));
         die($eh->getHtml($exc));
     }
 }
开发者ID:despark,项目名称:ignicms,代码行数:11,代码来源:View.php

示例10: cssAction

 /**
  * Renders the exception panel stylesheet for the given token.
  *
  * @param string $token The profiler token
  *
  * @return Response A Response instance
  *
  * @throws NotFoundHttpException
  */
 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($this->debug, $this->twig->getCharset());
         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'));
 }
开发者ID:xingshanghe,项目名称:symfony,代码行数:23,代码来源:ExceptionController.php

示例11: showAction

 /**
  * @param Request          $request
  * @param FlattenException $exception
  * @param string           $format
  */
 public function showAction(Request $request, FlattenException $exception, $format)
 {
     $handler = new ExceptionHandler($this->pimple['debug']);
     if ($this->pimple['debug']) {
         return $handler->createResponse($exception);
     }
     $code = $exception->getStatusCode();
     $template = $this->resolve($request, $code, $format);
     if ($template) {
         $contents = $this->pimple['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);
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:19,代码来源:ExceptionController.php

示例12: enable

 /**
  * Enables the debug tools.
  *
  * This method registers an error handler and an exception handler.
  *
  * If the Symfony ClassLoader component is available, a special
  * class loader is also registered.
  *
  * @param int  $errorReportingLevel The level of error reporting you want
  * @param bool $displayErrors       Whether to display errors (for development) or just log them (for production)
  */
 public static function enable($errorReportingLevel = null, $displayErrors = true)
 {
     if (static::$enabled) {
         return;
     }
     static::$enabled = true;
     if ($errorReportingLevel !== null) {
         error_reporting($errorReportingLevel);
     } else {
         error_reporting(-1);
     }
     if ('cli' !== php_sapi_name()) {
         ini_set('display_errors', 0);
         ExceptionHandler::register();
     } else {
         if ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
             // CLI - display errors only if they're not already logged to STDERR
             ini_set('display_errors', 1);
         }
     }
     if ($displayErrors) {
         error_handler::register(new error_handler(new BufferingLogger()));
     } else {
         error_handler::register()->throwAt(0, true);
     }
     DebugClassLoader::enable();
 }
开发者ID:VOLKERMORD,项目名称:phpbb,代码行数:38,代码来源:debug.php

示例13: bootstrap

 public function bootstrap()
 {
     $app = $this;
     $app['dir.base'] = __DIR__ . "/../../../../";
     $app->register(new ConfigServiceProvider());
     $app['debug'] = $app['config']['debug'];
     ErrorHandler::register();
     ExceptionHandler::register($app['debug']);
     $app->register(new HttpFragmentServiceProvider());
     $app->register(new ServiceControllerServiceProvider());
     $app->register(new ORMServiceProvider());
     $app->register(new SessionServiceProvider());
     $app->register(new SecurityServiceProvider());
     $app['security.encoder.digest'] = function ($app) {
         // uses the password-compat encryption
         return new BCryptPasswordEncoder(10);
     };
     $app->register(new ManagerRegistryServiceProvider());
     $app['security.firewalls'] = array('default' => array('pattern' => '/', 'form' => array('login_path' => '/login', 'check_path' => '/login_check'), 'logout' => array('logout_path' => '/logout', 'invalidate_session' => true), 'users' => function () use($app) {
         return new EntityUserProvider($app['manager_registry'], User::class, 'username');
     }, 'anonymous' => true));
     $app['security.access_rules'] = [['^/admin', 'ROLE_ADMIN']];
     $app->register(new TranslationServiceProvider(), array('locale_fallbacks' => array('en'), 'locale' => 'en'));
     $app->register(new ValidatorServiceProvider());
     $app->register(new FormServiceProvider());
     $app->register(new TwigServiceProvider(), ['twig.path' => __DIR__ . '/../resources/views', 'twig.form.templates' => ['bootstrap_3_layout.html.twig'], 'twig.strict_variables' => false]);
     $app->extend('twig', function (\Twig_Environment $twig) {
         $twig->addTest(new \Twig_SimpleTest('callable', function ($variable) {
             return is_callable($variable);
         }));
         $twig->addFunction(new \Twig_SimpleFunction('is_callable', function ($variable) {
             return is_callable($variable);
         }));
         $twig->addFunction(new \Twig_SimpleFunction('call_user_func', function ($callable, $params = null) {
             return call_user_func($callable, $params);
         }));
         $twig->getExtension('core')->setDateFormat('Y/m/d', '%d days');
         return $twig;
     });
     $app->extend('form.types', function ($types) use($app) {
         $types[] = new EntityType($app['manager_registry']);
         $types[] = new TemplateChoiceType($app['theme']);
         $types[] = new PageType($app['theme']);
         return $types;
     });
     $app->register(new SerializerServiceProvider());
     $app->register(new WebProfilerServiceProvider(), ['profiler.cache_dir' => './../storage/framework/cache/profiler', 'web_profiler.debug_toolbar.enable' => $app['debug'], 'profiler.mount_prefix' => '/admin/_profiler']);
     $app['finder'] = function () {
         return new Finder();
     };
     $app['filesystem'] = function () {
         return new Filesystem();
     };
     $app->register(new ConverterServiceProvider());
     $app->register(new ThemeServiceProvider());
     $app['twig.loader.filesystem']->addPath($app['dir.theme'], 'theme');
     $app->register(new CMSServiceProvider());
     $app->setRoutes();
 }
开发者ID:cmsilex,项目名称:cmsilex,代码行数:59,代码来源:Application.php

示例14: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof HttpResponseException) {
         return $e->getResponse();
     } elseif ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     } elseif ($e instanceof AuthorizationException) {
         $e = new HttpException(403, $e->getMessage());
     } elseif ($e instanceof ValidationException && $e->getResponse()) {
         return $e->getResponse();
     }
     $fe = FlattenException::create($e);
     $handler = new SymfonyExceptionHandler(env('APP_DEBUG', false));
     $decorated = $this->decorate($handler->getContent($fe), $handler->getStylesheet($fe));
     $response = new Response($decorated, $fe->getStatusCode(), $fe->getHeaders());
     $response->exception = $e;
     return $response;
 }
开发者ID:jonathanpmartins,项目名称:lumen-framework,代码行数:25,代码来源:Handler.php

示例15: register

 public function register(Application $app)
 {
     $debug = isset($app['config']) ? $app['config']['app.debug'] : true;
     $handler = ExceptionHandler::register($debug);
     ErrorHandler::register(E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_RECOVERABLE_ERROR);
     if ($cli = $app->runningInConsole() or $debug) {
         ini_set('display_errors', 1);
     }
     $app['exception'] = $handler;
 }
开发者ID:jacobjjc,项目名称:PageKit-framework,代码行数:10,代码来源:ExceptionServiceProvider.php


注:本文中的Symfony\Component\Debug\ExceptionHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。