summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Fearn <Jeff.Fearn@gmail.com>2015-01-08 05:27:09 +0100
committerByron Jones <glob@mozilla.com>2015-01-08 05:27:09 +0100
commit0ed20de47a3a320029123164b0d36a1e6cc0cbab (patch)
tree13c8785fbe81eae68f535b22bf8276a8fbd4b964
parent38eddcc0f6b085dee5ae088145370916492cd96e (diff)
downloadbugzilla-0ed20de47a3a320029123164b0d36a1e6cc0cbab.tar.gz
bugzilla-0ed20de47a3a320029123164b0d36a1e6cc0cbab.tar.xz
Bug 1089475: Use "ThrowCodeError" when a database error occurs instead of dumping a stack trace
-rw-r--r--Bugzilla/DB.pm15
-rw-r--r--template/en/default/global/code-error.html.tmpl4
2 files changed, 18 insertions, 1 deletions
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm
index 616f4768e..588d5ae50 100644
--- a/Bugzilla/DB.pm
+++ b/Bugzilla/DB.pm
@@ -167,7 +167,20 @@ sub _handle_error {
# Cut down the error string to a reasonable size
$_[0] = substr($_[0], 0, 2000) . ' ... ' . substr($_[0], -2000)
if length($_[0]) > 4000;
- # BMO: stracktrace disabled: $_[0] = Carp::longmess($_[0]);
+ # BMO: stracktrace disabled:
+ # $_[0] = Carp::longmess($_[0]);
+
+ # BMO: catch long running query timeouts and translate into a sane message
+ if ($_[0] =~ /Lost connection to MySQL server during query/) {
+ warn(Carp::longmess($_[0]));
+ $_[0] = "The database query took too long to complete and has been canceled.\n"
+ . "(Lost connection to MySQL server during query)";
+ }
+
+ if (Bugzilla->usage_mode == USAGE_MODE_BROWSER) {
+ ThrowCodeError("db_error", { err_message => $_[0] });
+ }
+
return 0; # Now let DBI handle raising the error
}
diff --git a/template/en/default/global/code-error.html.tmpl b/template/en/default/global/code-error.html.tmpl
index 62442c268..672c8b29d 100644
--- a/template/en/default/global/code-error.html.tmpl
+++ b/template/en/default/global/code-error.html.tmpl
@@ -123,6 +123,10 @@
[% ELSIF error == "comment_type_invalid" %]
'[% type FILTER html %]' is not a valid comment type.
+ [% ELSIF error == "db_error" %]
+ An error occurred while performing a database operation:<br>
+ <code>[% err_message FILTER html FILTER html_line_break %]</code>
+
[% ELSIF error == "db_rename_conflict" %]
Name conflict: Cannot rename [% old FILTER html %] to
[%+ new FILTER html %] because [% new FILTER html %] already exists.