From: gerv%gerv.net <> Date: Sat, 6 Apr 2002 04:03:06 +0000 (+0000) Subject: Bug 126456 - fix our error handling. Change the name of the functions to something... X-Git-Tag: bugzilla-2.16rc1~134 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53ebea8e40ed58dae86f11ef17da737143f550ab;p=thirdparty%2Fbugzilla.git Bug 126456 - fix our error handling. Change the name of the functions to something more sane; a few enhancements. Patch by gerv, 2xr=myk. --- diff --git a/CGI.pl b/CGI.pl index 2971d0899a..26c3020501 100644 --- a/CGI.pl +++ b/CGI.pl @@ -1208,22 +1208,22 @@ sub PutFooter { # done the header. ############################################################################### -# DisplayError is deprecated. Use CodeError, UserError or TemplateError -# instead. +# DisplayError is deprecated. Use ThrowCodeError, ThrowUserError or +# ThrowTemplateError instead. sub DisplayError { ($vars->{'error'}, $vars->{'title'}) = (@_); $vars->{'title'} ||= "Error"; print "Content-type: text/html\n\n" if !$vars->{'header_done'}; $template->process("global/user-error.html.tmpl", $vars) - || TemplateError($template->error()); + || ThrowTemplateError($template->error()); return 1; } # For "this shouldn't happen"-type places in the code. # $vars->{'variables'} is a reference to a hash of useful debugging info. -sub CodeError { +sub ThrowCodeError { ($vars->{'error'}, $vars->{'variables'}) = (@_); $vars->{'title'} = "Code Error"; @@ -1231,13 +1231,13 @@ sub CodeError { print "Content-type: text/html\n\n" if !$vars->{'header_done'}; $template->process("global/code-error.html.tmpl", $vars) - || TemplateError($template->error()); + || ThrowTemplateError($template->error()); exit; } # For errors made by the user. -sub UserError { +sub ThrowUserError { ($vars->{'error'}, $vars->{'title'}, my $unlock_tables) = (@_); $vars->{'title'} ||= "Error"; @@ -1245,24 +1245,33 @@ sub UserError { print "Content-type: text/html\n\n" if !$vars->{'header_done'}; $template->process("global/user-error.html.tmpl", $vars) - || TemplateError($template->error()); + || ThrowTemplateError($template->error()); exit; } -# If the template system isn't working, we can't use a template :-) +# If the template system isn't working, we can't use a template. +# This should only be called if a template->process() fails. # The Content-Type will already have been printed. -sub TemplateError { +sub ThrowTemplateError { my ($error) = html_quote((@_)); + my $maintainer = Param('maintainer'); - print "

- Bugzilla has suffered an internal error. Please save this page, and its - URL, and send it to "; - print Param("maintainer"); - print ", with details of what you were doing at the time this message - appeared.

-

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

+ +END + exit; } @@ -1274,7 +1283,7 @@ sub PuntTryAgain ($) { $vars->{'header_done'} = "true"; $template->process("global/user-error.html.tmpl", $vars) - || TemplateError($template->error()); + || ThrowTemplateError($template->error()); exit; } @@ -1410,7 +1419,7 @@ Actions: }; if ($loggedin) { if ($::anyvotesallowed) { - $html .= " | My votes\n"; + $html .= " | My votes\n"; } } if ($loggedin) { diff --git a/template/default/global/code-error.html.tmpl b/template/default/global/code-error.html.tmpl index 47987729a3..9f1fe29643 100644 --- a/template/default/global/code-error.html.tmpl +++ b/template/default/global/code-error.html.tmpl @@ -23,13 +23,17 @@ [% INCLUDE global/header %] [% END %] -

- - Bugzilla has suffered an internal error. Please save this page and send - it, and its URL, to [% Param("maintainer") %], with details of what you - were doing at the time this message appeared. - -

+ +

+ Bugzilla has suffered an internal error. Please save this page and send + it to [% Param("maintainer") %] with details of what you were doing at + the time this message appeared. +

+ +
@@ -41,11 +45,13 @@
-
+[% IF variables %]
+  
 Variables:
   [% FOREACH key = variables.keys %]
     [%+ key %]: [%+ variables.$key %]
   [% END %]
-
+
+[% END %] [% INCLUDE global/footer %]