Skip to content

Commit a1e61e9

Browse files
authored
Fix errors on creating new entries (#6)
2 parents eb5ef26 + 9690f69 commit a1e61e9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Typesense/Index.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Statamic\Search\Index as BaseIndex;
99
use Statamic\Support\Arr;
1010
use Typesense\Client;
11+
use Typesense\Exceptions\ObjectNotFound;
1112
use Typesense\Exceptions\TypesenseClientError;
1213

1314
class Index extends BaseIndex
@@ -53,7 +54,11 @@ public function insertMultiple($documents)
5354

5455
public function delete($document)
5556
{
56-
$this->getOrCreateIndex()->documents[$document->getSearchReference()]?->delete();
57+
try {
58+
$this->getOrCreateIndex()->documents[$document->getSearchReference()]?->delete();
59+
} catch (ObjectNotFound $e) {
60+
// do nothing, this just prevents errors bubbling up when the document doesnt exist
61+
}
5762
}
5863

5964
public function exists()

0 commit comments

Comments
 (0)