mirror of
				https://github.com/pragma-/pbot.git
				synced 2025-11-04 08:37:24 +01:00 
			
		
		
		
	Plugins/GoogleSearch: catch search() exceptions
This commit is contained in:
		
							parent
							
								
									1ba71c4970
								
							
						
					
					
						commit
						fd125849e2
					
				@ -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"; }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user