summaryrefslogtreecommitdiffstats
path: root/CGI.pl
diff options
context:
space:
mode:
authorgerv%gerv.net <>2002-04-29 07:09:38 +0200
committergerv%gerv.net <>2002-04-29 07:09:38 +0200
commit0bb934c7876696b29c43df06abcb81bbc7ebbce4 (patch)
tree146cee76a709208a7dbd794e12c6399ebc03adc9 /CGI.pl
parentb95d29942e8a3f6c68863b62170c58733d6c8d36 (diff)
downloadbugzilla-0bb934c7876696b29c43df06abcb81bbc7ebbce4.tar.gz
bugzilla-0bb934c7876696b29c43df06abcb81bbc7ebbce4.tar.xz
Bug 140006 - ThrowTemplateError should try a template before using print statements. Patch by gerv, r=bbaetz, justdave.
Diffstat (limited to 'CGI.pl')
-rw-r--r--CGI.pl41
1 files changed, 25 insertions, 16 deletions
diff --git a/CGI.pl b/CGI.pl
index 979ffda0d..bcbb08d25 100644
--- a/CGI.pl
+++ b/CGI.pl
@@ -916,24 +916,33 @@ sub ThrowUserError {
# This should only be called if a template->process() fails.
# The Content-Type will already have been printed.
sub ThrowTemplateError {
- my ($error) = html_quote((@_));
- my $maintainer = Param('maintainer');
+ ($vars->{'error'}) = (@_);
+ $vars->{'title'} = "Template Error";
- print <<END;
- <tt>
- <p>
- Bugzilla has suffered an internal error. Please save this page and send
- it to $maintainer with details of what you were doing at the time this
- message appeared.
- </p>
- <script> <!--
- document.write("<p>URL: " + document.location + "</p>");
- // -->
- </script>
- <p>Template->process() failed: $error</p>
- </tt>
+ # Try a template first; but if this one fails too, fall back
+ # on plain old print statements.
+ if (!$template->process("global/code-error.html.tmpl", $vars)) {
+ my $maintainer = Param('maintainer');
+ my $error = html_quote($vars->{'error'});
+ my $error2 = html_quote($template->error());
+ print <<END;
+ <tt>
+ <p>
+ Bugzilla has suffered an internal error. Please save this page and
+ send it to $maintainer with details of what you were doing at the
+ time this message appeared.
+ </p>
+ <script> <!--
+ document.write("<p>URL: " + document.location + "</p>");
+ // -->
+ </script>
+ <p>Template->process() failed twice.<br>
+ First error: $error<br>
+ Second error: $error2</p>
+ </tt>
END
-
+ }
+
exit;
}