From: Jeff Fearn Date: Wed, 3 Jun 2015 15:01:41 +0000 (+0800) Subject: Bug 1089475: Use "ThrowCodeError" when a database error occurs instead of dumping... X-Git-Tag: release-5.1.1~239 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db6b722ddca04ee1d067e010abc3e8e7fd9384c4;p=thirdparty%2Fbugzilla.git Bug 1089475: Use "ThrowCodeError" when a database error occurs instead of dumping a stack trace r=glob,a=glob --- diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index 9f3ed0f494..adf55f3519 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -142,6 +142,14 @@ sub _handle_error { $_[0] = substr($_[0], 0, 2000) . ' ... ' . substr($_[0], -2000) if length($_[0]) > 4000; $_[0] = Carp::longmess($_[0]); + + if (!Bugzilla->request_cache->{in_error} && Bugzilla->usage_mode == USAGE_MODE_BROWSER) { + Bugzilla->request_cache->{in_error} = 1; + ThrowCodeError("db_error", {err_message => $_[0]}); + } + + Bugzilla->request_cache->{in_error} = undef; + 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 d73d75e135..a242c74712 100644 --- a/template/en/default/global/code-error.html.tmpl +++ b/template/en/default/global/code-error.html.tmpl @@ -104,6 +104,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: +
[% err_message FILTER html %]
+ [% ELSIF error == "db_rename_conflict" %] Name conflict: Cannot rename [% old FILTER html %] to [%+ new FILTER html %] because [% new FILTER html %] already exists.