3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-01-22 18:14:48 +01:00

Plugins/GoogleSearch: catch search() exceptions

This commit is contained in:
Pragmatic Software 2020-05-04 18:43:50 -07:00
parent 1ba71c4970
commit fd125849e2

View File

@ -74,7 +74,14 @@ sub cmd_googlesearch {
. $result2->items->[0]->link . ">";
}
my $result = $engine->search($context->{arguments});
my $result = eval { $engine->search($context->{arguments}) };
if ($@) {
my $error = $@;
$error =~ s/^WWW::Google::CustomSearch::search\(\): /google: /;
$error =~ s/file .*$//;
return $error;
}
if (not defined $result or not defined $result->items or not @{$result->items}) { return "$context->{nick}: No results found"; }