當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ExceptionHandler::createResponse方法代碼示例

本文整理匯總了PHP中Symfony\Component\Debug\ExceptionHandler::createResponse方法的典型用法代碼示例。如果您正苦於以下問題:PHP ExceptionHandler::createResponse方法的具體用法?PHP ExceptionHandler::createResponse怎麽用?PHP ExceptionHandler::createResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Debug\ExceptionHandler的用法示例。


在下文中一共展示了ExceptionHandler::createResponse方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: display

 /**
  * Display the given exception to the user.
  *
  * @param  \Exception  $exception
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function display(Exception $exception)
 {
     if ($this->returnJson) {
         return new JsonResponse(array('error' => $exception->getMessage(), 'file' => $exception->getFile(), 'line' => $exception->getLine()), 500);
     }
     return $this->symfony->createResponse($exception);
 }
開發者ID:LuckyCyborg,項目名稱:simple-mvc-framework,代碼行數:13,代碼來源:SymfonyDisplayer.php

示例2: 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

示例3: createResponse

 /**
  * {@inheritdoc}
  */
 public function createResponse($exception)
 {
     if ($exception instanceof HttpException) {
         $exception = FlattenException::create($exception, $exception->getCode());
     }
     return parent::createResponse($exception);
 }
開發者ID:pagekit,項目名稱:pagekit,代碼行數:10,代碼來源:ExceptionHandler.php

示例4: 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

示例5: createResponseBasedOnRequest

 public function createResponseBasedOnRequest(Request $request, $exception)
 {
     return parent::createResponse($exception);
 }
開發者ID:luisbrito,項目名稱:Phraseanet,代碼行數:4,代碼來源:PhraseaExceptionHandler.php

示例6: display

 /**
  * Display the given exception to the user.
  *
  * @param  \Exception  $exception
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function display(Exception $exception)
 {
     return $this->symfony->createResponse($exception);
 }
開發者ID:arifmahmudrana,項目名稱:angularjs-laravel-boilerplate,代碼行數:10,代碼來源:SymfonyDisplayer.php

示例7: testNestedExceptions

 public function testNestedExceptions()
 {
     $handler = new ExceptionHandler(true);
     $response = $handler->createResponse(new \RuntimeException('Foo', null, new \RuntimeException('Bar')));
 }
開發者ID:yashb,項目名稱:generator,代碼行數:5,代碼來源:ExceptionHandlerTest.php

示例8: getResponse

 /**
  * Return response from CI
  *
  * @param Request $request
  *
  * @return Response
  *
  * @throws \Exception
  */
 public function getResponse(Request $request)
 {
     if (self::$ciLoaded) {
         throw new \Exception('Can not create response for CodeIgniter controller, because another controller was already loaded.');
     }
     self::$ciLoaded = true;
     $this->unsetNoticeErrorLevel();
     $this->setCiPaths($request);
     require_once __DIR__ . '/ci_bootstrap.php';
     try {
         ob_start();
         /*
          * --------------------------------------------------------------------
          * LOAD THE BOOTSTRAP FILE
          * --------------------------------------------------------------------
          *
          * And away we go...
          *
          */
         \ci_bootstrap($this->kernel);
         $response = new Response(ob_get_clean());
     } catch (\Exception $e) {
         ob_get_clean();
         $handler = new ExceptionHandler();
         $response = $handler->createResponse($e);
     }
     return $response;
 }
開發者ID:BahuL,項目名稱:NercuryCodeIgniterBundle,代碼行數:37,代碼來源:CiHelperService.php


注:本文中的Symfony\Component\Debug\ExceptionHandler::createResponse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。