Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit d0ba63a

Browse files
Merge pull request #6 from manavo/no-404s-when-deleting
Don't throw ObjectNotFound exceptions when deleting
2 parents 53317ab + b9813c6 commit d0ba63a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Engines/TypesenseSearchEngine.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Database\Eloquent\Model;
99
use Devloops\LaravelTypesense\Typesense;
1010
use GuzzleHttp\Exception\GuzzleException;
11+
use Typesense\Exceptions\ObjectNotFound;
1112
use Typesense\Exceptions\TypesenseClientError;
1213

1314
/**
@@ -57,10 +58,14 @@ public function delete($models): void
5758
function (Model $model) {
5859
$collectionIndex = $this->typesense->getCollectionIndex($model);
5960

60-
$this->typesense->deleteDocument(
61-
$collectionIndex,
62-
$model->{$model->getKey()}
63-
);
61+
try {
62+
$this->typesense->deleteDocument(
63+
$collectionIndex,
64+
$model->{$model->getKey()}
65+
);
66+
} catch (ObjectNotFound $e) {
67+
// Don't need to do anything here. The object wasn't found anyway, so nothing to delete!
68+
}
6469
}
6570
);
6671
}

0 commit comments

Comments
 (0)