From fd125849e25ca557d101ede09454f8db42672434 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Mon, 4 May 2020 18:43:50 -0700 Subject: [PATCH] Plugins/GoogleSearch: catch search() exceptions --- Plugins/GoogleSearch.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Plugins/GoogleSearch.pm b/Plugins/GoogleSearch.pm index da5e982a..2928cd3f 100644 --- a/Plugins/GoogleSearch.pm +++ b/Plugins/GoogleSearch.pm @@ -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"; }