Skip to content

Commit

Permalink
feat: Rename BlockFailedException to AlreadyBlockedException
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexejLeinweber committed Jan 28, 2025
1 parent 6e02db4 commit b5c9440
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Blocker.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Brainbits\Blocking;

use Brainbits\Blocking\Exception\BlockFailedException;
use Brainbits\Blocking\Exception\AlreadyBlockedException;
use Brainbits\Blocking\Identity\BlockIdentity;
use Brainbits\Blocking\Owner\OwnerFactoryInterface;
use Brainbits\Blocking\Storage\StorageInterface;
Expand All @@ -32,7 +32,7 @@ public function block(BlockIdentity $identifier, int|null $ttl = null): Block
$block = $this->tryBlock($identifier, $ttl);

if ($block === null) {
throw BlockFailedException::createAlreadyBlocked($identifier);
throw AlreadyBlockedException::createAlreadyBlocked($identifier);
}

return $block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use function sprintf;

class BlockFailedException extends RuntimeException
class AlreadyBlockedException extends RuntimeException
{
public static function createAlreadyBlocked(BlockIdentity $identity): self
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Brainbits\Blocking\Tests\Functional;

use Brainbits\Blocking\Blocker;
use Brainbits\Blocking\Exception\BlockFailedException;
use Brainbits\Blocking\Exception\AlreadyBlockedException;
use Brainbits\Blocking\Identity\BlockIdentity;
use Brainbits\Blocking\Owner\ValueOwnerFactory;
use Brainbits\Blocking\Storage\FilesystemStorage;
Expand Down Expand Up @@ -61,7 +61,7 @@ public function testSelfBlock(): void

public function testOtherBlock(): void
{
$this->expectException(BlockFailedException::class);
$this->expectException(AlreadyBlockedException::class);
$this->expectExceptionMessage('Identifier my_item is already blocked.');

file_put_contents(
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/InMemoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Brainbits\Blocking\Block;
use Brainbits\Blocking\Blocker;
use Brainbits\Blocking\Exception\BlockFailedException;
use Brainbits\Blocking\Exception\AlreadyBlockedException;
use Brainbits\Blocking\Identity\BlockIdentity;
use Brainbits\Blocking\Owner\Owner;
use Brainbits\Blocking\Owner\ValueOwnerFactory;
Expand Down Expand Up @@ -56,7 +56,7 @@ public function testSelfBlock(): void

public function testOtherBlock(): void
{
$this->expectException(BlockFailedException::class);
$this->expectException(AlreadyBlockedException::class);
$this->expectExceptionMessage('Identifier my_item is already blocked.');

$storage = new InMemoryStorage($this->clock);
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/PredisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Brainbits\Blocking\Tests\Functional;

use Brainbits\Blocking\Blocker;
use Brainbits\Blocking\Exception\BlockFailedException;
use Brainbits\Blocking\Exception\AlreadyBlockedException;
use Brainbits\Blocking\Identity\BlockIdentity;
use Brainbits\Blocking\Owner\ValueOwnerFactory;
use Brainbits\Blocking\Storage\PredisStorage;
Expand Down Expand Up @@ -67,7 +67,7 @@ public function testSelfBlock(): void

public function testOtherBlock(): void
{
$this->expectException(BlockFailedException::class);
$this->expectException(AlreadyBlockedException::class);
$this->expectExceptionMessage('Identifier my_item is already blocked.');

$this->client->set('block:my_item', json_encode(['identity' => 'my_item', 'owner' => 'other_owner']));
Expand Down

0 comments on commit b5c9440

Please sign in to comment.