Skip to content

Commit

Permalink
✨ Throw an exception if index couldn't be marked as live, as otherwis…
Browse files Browse the repository at this point in the history
…e the problem wasn't explicit

Signed-off-by: Jean-Pascal Devierne <jean-pascal@novaway.fr>
  • Loading branch information
Jean-Pascal Devierne committed Feb 25, 2020
1 parent 96a8c0f commit 8efc487
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Provider/IndexProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public function rebuildIndex($markAsLive = true, $removeOldIndexes = true): Inde
* @param Index $index The index to link to the $this->name alias
* @param bool $removeOldIndexes If true, remove the indexes currently linked to $this->name alias after marking $index as live
*
* @throws \Exception if the index couldn't be marked as live
*
* @return bool index is markedAsLive
*/
public function markAsLive(Index $index, bool $removeOldIndexes = true): bool
Expand All @@ -95,7 +97,7 @@ public function markAsLive(Index $index, bool $removeOldIndexes = true): bool
}
// and delete the failed one
$index->delete();
return false;
throw $e;
}
if ($removeOldIndexes) {
// if everything went well, the new index is set as the alias
Expand All @@ -109,7 +111,7 @@ public function markAsLive(Index $index, bool $removeOldIndexes = true): bool

return true;
}

protected function getIndexByName($name): Index
{
return new Index($this->eventDispatcher, $this->client, $name);
Expand Down

0 comments on commit 8efc487

Please sign in to comment.