OneTicketPerRequestor: Catch and report errors in the ticket search.

This commit is contained in:
Brett Smith 2018-04-10 10:44:13 -04:00
parent daeabc1aa6
commit d7a24b0f97

View file

@ -77,22 +77,27 @@ sub BeforeDecrypt {
return;
}
my $ticket_search = RT::Tickets->new($RT::SystemUser);
$ticket_search->LimitQueue(
OPERATOR => "=",
VALUE => $queue_name,
);
$ticket_search->LimitWatcher(
TYPE => "Requestor",
OPERATOR => "=",
VALUE => $from_address,
);
foreach my $sort_args (@$sort_orders) {
$ticket_search->OrderBy(@$sort_args);
my $dest_ticket = eval {
my $ticket_search = RT::Tickets->new($RT::SystemUser);
$ticket_search->LimitQueue(
OPERATOR => "=",
VALUE => $queue_name,
);
$ticket_search->LimitWatcher(
TYPE => "Requestor",
OPERATOR => "=",
VALUE => $from_address,
);
foreach my $sort_args (@$sort_orders) {
$ticket_search->OrderBy(@$sort_args);
}
$ticket_search->First;
};
if ($@) {
$RT::Logger->debug("OTPR stopping: Ticket search died: $@");
return;
}
my $dest_ticket = $ticket_search->First;
if (!defined($dest_ticket)) {
elsif (!defined($dest_ticket)) {
$RT::Logger->debug(sprintf("OTPR stopping: No ticket found from <%s> in queue %s",
$from_address, $queue_name));
return;