From bd4dcb0484989284ea76efe567dd612a32de1ddf Mon Sep 17 00:00:00 2001 From: Jeff Fearn Date: Wed, 17 Dec 2014 13:09:01 +0800 Subject: Bug 1089475: Use "ThrowCodeError" when a database error occurs instead of dumping a stack trace r=glob,a=glob --- Bugzilla/DB.pm | 5 +++++ template/en/default/global/code-error.html.tmpl | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index 9f3ed0f49..afe728ca7 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -142,6 +142,11 @@ sub _handle_error { $_[0] = substr($_[0], 0, 2000) . ' ... ' . substr($_[0], -2000) if length($_[0]) > 4000; $_[0] = Carp::longmess($_[0]); + + 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 1c3422fa8..a4a4962dd 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. -- cgit v1.2.3-24-g4f1b