本文整理汇总了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);
}
示例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);
}
示例3: createResponse
/**
* {@inheritdoc}
*/
public function createResponse($exception)
{
if ($exception instanceof HttpException) {
$exception = FlattenException::create($exception, $exception->getCode());
}
return parent::createResponse($exception);
}
示例4: onSilexError
public function onSilexError(GetResponseForExceptionEvent $event)
{
if (!$this->enabled) {
return;
}
$handler = new DebugExceptionHandler($this->debug);
$event->setResponse($handler->createResponse($event->getException()));
}
示例5: createResponseBasedOnRequest
public function createResponseBasedOnRequest(Request $request, $exception)
{
return parent::createResponse($exception);
}
示例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);
}
示例7: testNestedExceptions
public function testNestedExceptions()
{
$handler = new ExceptionHandler(true);
$response = $handler->createResponse(new \RuntimeException('Foo', null, new \RuntimeException('Bar')));
}
示例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;
}