Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TwigBundle] add back exception check #23283

Merged
merged 1 commit into from Jun 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -125,7 +125,7 @@ protected function findTemplate(Request $request, $format, $code, $showException
// default to a generic HTML exception
$request->setRequestFormat('html');

return new TemplateReference('TwigBundle', 'Exception', $name, 'html', 'twig');
return new TemplateReference('TwigBundle', 'Exception', $showException ? 'exception_full' : $name, 'html', 'twig');
}

// to be removed when the minimum required version of Twig is >= 3.0
Expand Down
Expand Up @@ -48,6 +48,20 @@ public function testFallbackToHtmlIfNoTemplateForRequestedFormat()
$this->assertEquals('html', $request->getRequestFormat());
}

public function testFallbackToHtmlWithFullExceptionIfNoTemplateForRequestedFormatAndExceptionsShouldBeShown()
{
$twig = $this->createTwigEnv(array('TwigBundle:Exception:exception_full.html.twig' => '<html></html>'));

$request = $this->createRequest('txt');
$request->attributes->set('showException', true);
$exception = FlattenException::create(new \Exception());
$controller = new ExceptionController($twig, false);

$controller->showAction($request, $exception);

$this->assertEquals('html', $request->getRequestFormat());
}

public function testResponseHasRequestedMimeType()
{
$twig = $this->createTwigEnv(array('TwigBundle:Exception:error.json.twig' => '{}'));
Expand Down