From 0bb934c7876696b29c43df06abcb81bbc7ebbce4 Mon Sep 17 00:00:00 2001 From: "gerv%gerv.net" <> Date: Mon, 29 Apr 2002 05:09:38 +0000 Subject: Bug 140006 - ThrowTemplateError should try a template before using print statements. Patch by gerv, r=bbaetz, justdave. --- CGI.pl | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'CGI.pl') 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 < -

- 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. -

- -

Template->process() failed: $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 < +

+ 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. +

+ +

Template->process() failed twice.
+ First error: $error
+ Second error: $error2

+ END - + } + exit; } -- cgit v1.2.3-24-g4f1b