Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
13ed7e91
Commit
13ed7e91
authored
Apr 04, 2002
by
gerv%gerv.net
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 126456 - improve our error handling. Patch by gerv, r=myk, bbaetz.
parent
9da893ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
156 additions
and
12 deletions
+156
-12
CGI.pl
CGI.pl
+67
-12
code-error.html.tmpl
template/default/global/code-error.html.tmpl
+50
-0
user-error.html.tmpl
template/default/global/user-error.html.tmpl
+39
-0
No files found.
CGI.pl
View file @
13ed7e91
...
...
@@ -52,6 +52,8 @@ use CGI::Carp qw(fatalsToBrowser);
require
'globals.pl'
;
use
vars
qw($template $vars)
;
# If Bugzilla is shut down, do not go any further, just display a message
# to the user about the downtime. (do)editparams.cgi is exempted from
# this message, of course, since it needs to be available in order for
...
...
@@ -1199,27 +1201,80 @@ sub PutFooter {
}
###############################################################################
# Error handling
#
# If you are doing incremental output, set $vars->{'header_done'} once you've
# done the header.
###############################################################################
# DisplayError is deprecated. Use CodeError, UserError or TemplateError
# instead.
sub
DisplayError
{
my
(
$message
,
$title
)
=
(
@_
);
$title
||=
"Error"
;
$message
||=
"An unknown error occurred."
;
(
$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
());
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
{
(
$vars
->
{
'error'
},
$vars
->
{
'variables'
})
=
(
@_
);
$vars
->
{
'title'
}
=
"Code Error"
;
# We may optionally log something to file here.
print
"Content-type: text/html\n\n"
;
PutHeader
(
$title
);
print
"Content-type: text/html\n\n"
if
!
$vars
->
{
'header_done'
};
$template
->
process
(
"global/code-error.html.tmpl"
,
$vars
)
||
TemplateError
(
$template
->
error
());
exit
;
}
print
PerformSubsts
(
Param
(
"errorhtml"
)
,
{
errormsg
=>
$message
}
);
# For errors made by the user.
sub
UserError
{
(
$vars
->
{
'error'
},
$vars
->
{
'title'
},
my
$unlock_tables
)
=
(
@_
);
$vars
->
{
'title'
}
||=
"Error"
;
PutFooter
();
SendSQL
(
"UNLOCK TABLES"
)
if
$unlock_tables
;
print
"Content-type: text/html\n\n"
if
!
$vars
->
{
'header_done'
};
$template
->
process
(
"global/user-error.html.tmpl"
,
$vars
)
||
TemplateError
(
$template
->
error
());
exit
;
}
return
1
;
# If the template system isn't working, we can't use a template :-)
# The Content-Type will already have been printed.
sub
TemplateError
{
my
(
$error
)
=
html_quote
((
@_
));
print
"<tt><p>
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.</p>
<p>Template->process() failed: $error.</p></tt>"
;
exit
;
}
# PuntTryAgain is deprecated. Use UserError with the unlock_tables parameter.
sub
PuntTryAgain
($)
{
my
(
$str
)
=
(
@_
);
print
PerformSubsts
(
Param
(
"errorhtml"
),
{
errormsg
=>
$str
});
(
$vars
->
{
'error'
})
=
(
@_
);
SendSQL
(
"UNLOCK TABLES"
);
PutFooter
();
$vars
->
{
'header_done'
}
=
"true"
;
$template
->
process
(
"global/user-error.html.tmpl"
,
$vars
)
||
TemplateError
(
$template
->
error
());
exit
;
}
...
...
template/default/global/code-error.html.tmpl
0 → 100644
View file @
13ed7e91
[%# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Gervase Markham <gerv@gerv.net>
#%]
[% UNLESS header_done %]
[% INCLUDE global/header %]
[% END %]
<p>
<tt>
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.
</tt>
</p>
<table cellpadding="20">
<tr>
<td bgcolor="#ff0000">
<font size="+2">
[% error %]
</font>
</td>
</tr>
</table>
<pre>
Variables:
[% FOREACH key = variables.keys %]
[%+ key %]: [%+ variables.$key %]
[% END %]
</pre>
[% INCLUDE global/footer %]
template/default/global/user-error.html.tmpl
0 → 100644
View file @
13ed7e91
[%# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Gervase Markham <gerv@gerv.net>
#%]
[% UNLESS header_done %]
[% INCLUDE global/header %]
[% END %]
<table cellpadding="20">
<tr>
<td bgcolor="#ff0000">
<font size="+2">
[% error %]
</font>
</td>
</tr>
</table>
<p>
Please press <b>Back</b> and try again.
</p>
[% INCLUDE global/footer %]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment