Skip to content

Commit

Permalink
Fix errors on creating new entries (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell authored Oct 31, 2024
2 parents eb5ef26 + 9690f69 commit a1e61e9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Typesense/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Statamic\Search\Index as BaseIndex;
use Statamic\Support\Arr;
use Typesense\Client;
use Typesense\Exceptions\ObjectNotFound;
use Typesense\Exceptions\TypesenseClientError;

class Index extends BaseIndex
Expand Down Expand Up @@ -53,7 +54,11 @@ public function insertMultiple($documents)

public function delete($document)
{
$this->getOrCreateIndex()->documents[$document->getSearchReference()]?->delete();
try {
$this->getOrCreateIndex()->documents[$document->getSearchReference()]?->delete();
} catch (ObjectNotFound $e) {
// do nothing, this just prevents errors bubbling up when the document doesnt exist
}
}

public function exists()
Expand Down

0 comments on commit a1e61e9

Please sign in to comment.