Bug 140006 - ThrowTemplateError should try a template before using print statements. Patch by gerv, r=bbaetz, justdave.

This commit is contained in:
gerv%gerv.net 2002-04-28 22:09:38 +00:00
parent 0aabe0f310
commit e56fdc0093

View File

@ -916,23 +916,32 @@ sub ThrowUserError {
# This should only be called if a template->process() fails. # This should only be called if a template->process() fails.
# The Content-Type will already have been printed. # The Content-Type will already have been printed.
sub ThrowTemplateError { sub ThrowTemplateError {
my ($error) = html_quote((@_)); ($vars->{'error'}) = (@_);
my $maintainer = Param('maintainer'); $vars->{'title'} = "Template Error";
# 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; print <<END;
<tt> <tt>
<p> <p>
Bugzilla has suffered an internal error. Please save this page and send Bugzilla has suffered an internal error. Please save this page and
it to $maintainer with details of what you were doing at the time this send it to $maintainer with details of what you were doing at the
message appeared. time this message appeared.
</p> </p>
<script> <!-- <script> <!--
document.write("<p>URL: " + document.location + "</p>"); document.write("<p>URL: " + document.location + "</p>");
// --> // -->
</script> </script>
<p>Template->process() failed: $error</p> <p>Template->process() failed twice.<br>
First error: $error<br>
Second error: $error2</p>
</tt> </tt>
END END
}
exit; exit;
} }