Commit 53ebea8e authored by gerv%gerv.net's avatar gerv%gerv.net

Bug 126456 - fix our error handling. Change the name of the functions to…

Bug 126456 - fix our error handling. Change the name of the functions to something more sane; a few enhancements. Patch by gerv, 2xr=myk.
parent 181d0442
...@@ -1208,22 +1208,22 @@ sub PutFooter { ...@@ -1208,22 +1208,22 @@ sub PutFooter {
# done the header. # done the header.
############################################################################### ###############################################################################
# DisplayError is deprecated. Use CodeError, UserError or TemplateError # DisplayError is deprecated. Use ThrowCodeError, ThrowUserError or
# instead. # ThrowTemplateError instead.
sub DisplayError { sub DisplayError {
($vars->{'error'}, $vars->{'title'}) = (@_); ($vars->{'error'}, $vars->{'title'}) = (@_);
$vars->{'title'} ||= "Error"; $vars->{'title'} ||= "Error";
print "Content-type: text/html\n\n" if !$vars->{'header_done'}; print "Content-type: text/html\n\n" if !$vars->{'header_done'};
$template->process("global/user-error.html.tmpl", $vars) $template->process("global/user-error.html.tmpl", $vars)
|| TemplateError($template->error()); || ThrowTemplateError($template->error());
return 1; return 1;
} }
# For "this shouldn't happen"-type places in the code. # For "this shouldn't happen"-type places in the code.
# $vars->{'variables'} is a reference to a hash of useful debugging info. # $vars->{'variables'} is a reference to a hash of useful debugging info.
sub CodeError { sub ThrowCodeError {
($vars->{'error'}, $vars->{'variables'}) = (@_); ($vars->{'error'}, $vars->{'variables'}) = (@_);
$vars->{'title'} = "Code Error"; $vars->{'title'} = "Code Error";
...@@ -1231,13 +1231,13 @@ sub CodeError { ...@@ -1231,13 +1231,13 @@ sub CodeError {
print "Content-type: text/html\n\n" if !$vars->{'header_done'}; print "Content-type: text/html\n\n" if !$vars->{'header_done'};
$template->process("global/code-error.html.tmpl", $vars) $template->process("global/code-error.html.tmpl", $vars)
|| TemplateError($template->error()); || ThrowTemplateError($template->error());
exit; exit;
} }
# For errors made by the user. # For errors made by the user.
sub UserError { sub ThrowUserError {
($vars->{'error'}, $vars->{'title'}, my $unlock_tables) = (@_); ($vars->{'error'}, $vars->{'title'}, my $unlock_tables) = (@_);
$vars->{'title'} ||= "Error"; $vars->{'title'} ||= "Error";
...@@ -1245,24 +1245,33 @@ sub UserError { ...@@ -1245,24 +1245,33 @@ sub UserError {
print "Content-type: text/html\n\n" if !$vars->{'header_done'}; print "Content-type: text/html\n\n" if !$vars->{'header_done'};
$template->process("global/user-error.html.tmpl", $vars) $template->process("global/user-error.html.tmpl", $vars)
|| TemplateError($template->error()); || ThrowTemplateError($template->error());
exit; 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. # The Content-Type will already have been printed.
sub TemplateError { sub ThrowTemplateError {
my ($error) = html_quote((@_)); my ($error) = html_quote((@_));
my $maintainer = Param('maintainer');
print "<tt><p> print <<END;
Bugzilla has suffered an internal error. Please save this page, and its <tt>
URL, and send it to "; <p>
print Param("maintainer"); Bugzilla has suffered an internal error. Please save this page and send
print ", with details of what you were doing at the time this message it to $maintainer with details of what you were doing at the time this
appeared.</p> message appeared.
<p>Template->process() failed: $error.</p></tt>"; </p>
<script> <!--
document.write("<p>URL: " + document.location + "</p>");
// -->
</script>
<p>Template->process() failed: $error</p>
</tt>
END
exit; exit;
} }
...@@ -1274,7 +1283,7 @@ sub PuntTryAgain ($) { ...@@ -1274,7 +1283,7 @@ sub PuntTryAgain ($) {
$vars->{'header_done'} = "true"; $vars->{'header_done'} = "true";
$template->process("global/user-error.html.tmpl", $vars) $template->process("global/user-error.html.tmpl", $vars)
|| TemplateError($template->error()); || ThrowTemplateError($template->error());
exit; exit;
} }
...@@ -1410,7 +1419,7 @@ Actions: ...@@ -1410,7 +1419,7 @@ Actions:
}; };
if ($loggedin) { if ($loggedin) {
if ($::anyvotesallowed) { if ($::anyvotesallowed) {
$html .= " | <A HREF=\"votes.cgi?action=show_user\">My votes</A>\n"; $html .= " | <A HREF=\"showvotes.cgi\">My votes</A>\n";
} }
} }
if ($loggedin) { if ($loggedin) {
......
...@@ -23,13 +23,17 @@ ...@@ -23,13 +23,17 @@
[% INCLUDE global/header %] [% INCLUDE global/header %]
[% END %] [% END %]
<p> <tt>
<tt> <p>
Bugzilla has suffered an internal error. Please save this page and send Bugzilla has suffered an internal error. Please save this page and send
it, and its URL, to [% Param("maintainer") %], with details of what you it to [% Param("maintainer") %] with details of what you were doing at
were doing at the time this message appeared. the time this message appeared.
</tt> </p>
</p> <script> <!--
document.write("<p>URL: " + document.location + "</p>");
// -->
</script>
</tt>
<table cellpadding="20"> <table cellpadding="20">
<tr> <tr>
...@@ -41,11 +45,13 @@ ...@@ -41,11 +45,13 @@
</tr> </tr>
</table> </table>
<pre> [% IF variables %]
<pre>
Variables: Variables:
[% FOREACH key = variables.keys %] [% FOREACH key = variables.keys %]
[%+ key %]: [%+ variables.$key %] [%+ key %]: [%+ variables.$key %]
[% END %] [% END %]
</pre> </pre>
[% END %]
[% INCLUDE global/footer %] [% INCLUDE global/footer %]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment