Skip to content

Commit 23c4e39

Browse files
committed
catch collections that don't exist
1 parent 841471e commit 23c4e39

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Console/Commands/DeleteIndex.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Laravel\Scout\EngineManager;
77
use Laravel\Scout\Engines\TypesenseEngine;
88
use RuntimeException;
9+
use Typesense\Exceptions\ObjectNotFound;
910

1011
class DeleteIndex extends Command
1112
{
@@ -47,7 +48,12 @@ public function handle(): int
4748
throw new RuntimeException('Cannot delete collection ' . $collectionName . ' because it is currently targeted by an alias.');
4849
}
4950

50-
$collections[$collectionName]->delete();
51+
try {
52+
$collections[$collectionName]->delete();
53+
$this->info("Collection {$collectionName} deleted");
54+
} catch (ObjectNotFound) {
55+
$this->line("No collection called {$collectionName} exists");
56+
}
5157
}
5258

5359
return Command::SUCCESS;

0 commit comments

Comments
 (0)