From: Frédéric Buclin Date: Sun, 27 Nov 2011 23:00:20 +0000 (+0100) Subject: Bug 277073: Make whining trap errors thrown by Search.pm X-Git-Tag: bugzilla-4.0.3~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0072b2d975bd3fec138c5e532e70c387062e37f6;p=thirdparty%2Fbugzilla.git Bug 277073: Make whining trap errors thrown by Search.pm r=wicked a=LpSolit --- diff --git a/template/en/default/global/messages.html.tmpl b/template/en/default/global/messages.html.tmpl index cad4758e26..52502a1d75 100644 --- a/template/en/default/global/messages.html.tmpl +++ b/template/en/default/global/messages.html.tmpl @@ -829,6 +829,10 @@ No changes made to version [% version.name FILTER html %]. [% END %] + [% ELSIF message_tag == "whine_query_failed" %] + The query '[% query_name FILTER html %]' from [% author.login FILTER html %] + failed: [% reason FILTER html %] + [% ELSIF message_tag == "workflow_updated" %] The workflow has been updated. [% END %] diff --git a/whine.pl b/whine.pl index 1f22b65fc4..12ad9a0e0c 100755 --- a/whine.pl +++ b/whine.pl @@ -444,11 +444,17 @@ sub run_queries { # Bugzilla::Search to execute a saved query. It's exceedingly weird, # but that's how it works. my $searchparams = new Bugzilla::CGI($savedquery); - my $search = new Bugzilla::Search( + my $search = eval { new Bugzilla::Search( 'fields' => \@searchfields, 'params' => $searchparams, 'user' => $args->{'recipient'}, # the search runs as the recipient - ); + ) }; + if ($@) { + print STDERR get_text('whine_query_failed', { query_name => $thisquery->{'name'}, + author => $args->{'author'}, + reason => $@ }) . "\n"; + next; + } my $sqlquery = $search->getSQL(); $sth = $dbh->prepare($sqlquery); $sth->execute;