Catch exception

This commit is contained in:
James Cole 2021-10-02 18:45:42 +02:00
parent ad8a8ae612
commit 0518c96567
No known key found for this signature in database
GPG Key ID: BDE6667570EADBD5

View File

@ -54,6 +54,7 @@ use Gdbots\QueryParser\QueryParser;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Log;
use TypeError;
/**
* Class OperatorQuerySearch
@ -152,7 +153,13 @@ class OperatorQuerySearch implements SearchInterface
{
Log::debug(sprintf('Now in parseQuery(%s)', $query));
$parser = new QueryParser();
$query1 = $parser->parse($query);
try {
$query1 = $parser->parse($query);
} catch (TypeError $e) {
Log::error($e->getMessage());
Log::error(sprintf('Could not parse search: "%s".', $query));
throw new FireflyException('Invalid search value. See the logs.', 0, $e);
}
Log::debug(sprintf('Found %d node(s)', count($query1->getNodes())));
foreach ($query1->getNodes() as $searchNode) {