diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig
index 397d68142a46..cc2e0ddf220c 100644
--- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig
+++ b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig
@@ -5,10 +5,10 @@
{{ trace.type ~ trace.function }}
({{ trace.args|format_args }})
-
{% endif %}
-{% if trace.file is defined and trace.line is defined %}
+{% if trace.file is defined and trace.file and trace.line is defined and trace.line %}
+ {{ trace.function ? '
' : '' }}
in {{ trace.file|format_file(trace.line) }}
{% spaceless %}