Skip to content

Commit

Permalink
rename almost all exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
prolic committed Jan 2, 2019
1 parent d086c3d commit 1fb9d87
Show file tree
Hide file tree
Showing 51 changed files with 191 additions and 191 deletions.
8 changes: 4 additions & 4 deletions src/ClientOperations/AbstractOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
use Amp\Deferred;
use Amp\Promise;
use Prooph\EventStore\EndPoint;
use Prooph\EventStore\Exception\NotAuthenticatedException;
use Prooph\EventStore\Exception\NotAuthenticated;
use Prooph\EventStore\Exception\ServerError;
use Prooph\EventStore\Exception\UnexpectedCommandException;
use Prooph\EventStore\Exception\UnexpectedCommand;
use Prooph\EventStore\UserCredentials;
use Prooph\EventStoreClient\Messages\ClientMessages\NotHandled;
use Prooph\EventStoreClient\Messages\ClientMessages\NotHandled_MasterInfo as MasterInfo;
Expand Down Expand Up @@ -138,7 +138,7 @@ public function fail(Throwable $exception): void

private function inspectNotAuthenticated(TcpPackage $package): InspectionResult
{
$this->fail(new NotAuthenticatedException());
$this->fail(new NotAuthenticated());

return new InspectionResult(InspectionDecision::endOperation(), 'Not authenticated');
}
Expand Down Expand Up @@ -200,7 +200,7 @@ private function inspectUnexpectedCommand(TcpPackage $package, TcpCommand $expec
$this->log->error('TcpPackage Data Dump:');
$this->log->error($package->data());

$exception = UnexpectedCommandException::with($expectedCommand->name(), $package->command()->name());
$exception = UnexpectedCommand::with($expectedCommand->name(), $package->command()->name());
$this->fail($exception);

return new InspectionResult(InspectionDecision::endOperation(), $exception->getMessage());
Expand Down
18 changes: 9 additions & 9 deletions src/ClientOperations/AbstractSubscriptionOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
use Generator;
use Prooph\EventStore\EndPoint;
use Prooph\EventStore\EventStoreSubscription;
use Prooph\EventStore\Exception\AccessDeniedException;
use Prooph\EventStore\Exception\ConnectionClosedException;
use Prooph\EventStore\Exception\NotAuthenticatedException;
use Prooph\EventStore\Exception\AccessDenied;
use Prooph\EventStore\Exception\ConnectionClosed;
use Prooph\EventStore\Exception\NotAuthenticated;
use Prooph\EventStore\Exception\RuntimeException;
use Prooph\EventStore\Exception\ServerError;
use Prooph\EventStore\Exception\UnexpectedCommandException;
use Prooph\EventStore\Exception\UnexpectedCommand;
use Prooph\EventStore\Internal\ResolvedEvent;
use Prooph\EventStore\SubscriptionDropReason;
use Prooph\EventStore\UserCredentials;
Expand Down Expand Up @@ -155,7 +155,7 @@ public function inspectPackage(TcpPackage $package): InspectionResult
$this->dropSubscription(SubscriptionDropReason::userInitiated(), null);
break;
case SubscriptionDropReasonMessage::AccessDenied:
$this->dropSubscription(SubscriptionDropReason::accessDenied(), new AccessDeniedException(\sprintf(
$this->dropSubscription(SubscriptionDropReason::accessDenied(), new AccessDenied(\sprintf(
'Subscription to \'%s\' failed due to access denied',
$this->streamId
)));
Expand All @@ -173,15 +173,15 @@ public function inspectPackage(TcpPackage $package): InspectionResult
$message->getReason()
));
}
$this->dropSubscription(SubscriptionDropReason::unknown(), new UnexpectedCommandException(
$this->dropSubscription(SubscriptionDropReason::unknown(), new UnexpectedCommand(
'Unsubscribe reason: ' . $message->getReason()
));
break;
}

return new InspectionResult(InspectionDecision::endOperation(), 'SubscriptionDropped: ' . $message->getReason());
case TcpCommand::NOT_AUTHENTICATED_EXCEPTION:
$this->dropSubscription(SubscriptionDropReason::notAuthenticated(), new NotAuthenticatedException());
$this->dropSubscription(SubscriptionDropReason::notAuthenticated(), new NotAuthenticated());

return new InspectionResult(InspectionDecision::endOperation(), 'NotAuthenticated');
case TcpCommand::BAD_REQUEST:
Expand Down Expand Up @@ -230,7 +230,7 @@ public function inspectPackage(TcpPackage $package): InspectionResult
default:
$this->dropSubscription(
SubscriptionDropReason::serverError(),
UnexpectedCommandException::withName($package->command()->name())
UnexpectedCommand::withName($package->command()->name())
);

return new InspectionResult(InspectionDecision::endOperation(), $package->command()->name());
Expand All @@ -247,7 +247,7 @@ public function connectionClosed(): void
{
$this->dropSubscription(
SubscriptionDropReason::connectionClosed(),
new ConnectionClosedException('Connection was closed')
new ConnectionClosed('Connection was closed')
);
}

Expand Down
16 changes: 8 additions & 8 deletions src/ClientOperations/AppendToStreamOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

use Amp\Deferred;
use Prooph\EventStore\EventData;
use Prooph\EventStore\Exception\AccessDeniedException;
use Prooph\EventStore\Exception\InvalidTransactionException;
use Prooph\EventStore\Exception\StreamDeletedException;
use Prooph\EventStore\Exception\AccessDenied;
use Prooph\EventStore\Exception\InvalidTransaction;
use Prooph\EventStore\Exception\StreamDeleted;
use Prooph\EventStore\Exception\UnexpectedOperationResult;
use Prooph\EventStore\Exception\WrongExpectedVersionException;
use Prooph\EventStore\Exception\WrongExpectedVersion;
use Prooph\EventStore\Position;
use Prooph\EventStore\UserCredentials;
use Prooph\EventStore\WriteResult;
Expand Down Expand Up @@ -105,25 +105,25 @@ protected function inspectResponse(ProtobufMessage $response): InspectionResult
case OperationResult::CommitTimeout:
return new InspectionResult(InspectionDecision::retry(), 'CommitTimeout');
case OperationResult::WrongExpectedVersion:
$this->fail(WrongExpectedVersionException::with(
$this->fail(WrongExpectedVersion::with(
$this->stream,
$this->expectedVersion,
$response->getCurrentVersion()
));

return new InspectionResult(InspectionDecision::endOperation(), 'WrongExpectedVersion');
case OperationResult::StreamDeleted:
$exception = StreamDeletedException::with($this->stream);
$exception = StreamDeleted::with($this->stream);
$this->fail($exception);

return new InspectionResult(InspectionDecision::endOperation(), 'StreamDeleted');
case OperationResult::InvalidTransaction:
$exception = new InvalidTransactionException();
$exception = new InvalidTransaction();
$this->fail($exception);

return new InspectionResult(InspectionDecision::endOperation(), 'InvalidTransaction');
case OperationResult::AccessDenied:
$exception = AccessDeniedException::toStream($this->stream);
$exception = AccessDenied::toStream($this->stream);
$this->fail($exception);

return new InspectionResult(InspectionDecision::endOperation(), 'AccessDenied');
Expand Down
16 changes: 8 additions & 8 deletions src/ClientOperations/CommitTransactionOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
namespace Prooph\EventStoreClient\ClientOperations;

use Amp\Deferred;
use Prooph\EventStore\Exception\AccessDeniedException;
use Prooph\EventStore\Exception\InvalidTransactionException;
use Prooph\EventStore\Exception\StreamDeletedException;
use Prooph\EventStore\Exception\AccessDenied;
use Prooph\EventStore\Exception\InvalidTransaction;
use Prooph\EventStore\Exception\StreamDeleted;
use Prooph\EventStore\Exception\UnexpectedOperationResult;
use Prooph\EventStore\Exception\WrongExpectedVersionException;
use Prooph\EventStore\Exception\WrongExpectedVersion;
use Prooph\EventStore\Position;
use Prooph\EventStore\UserCredentials;
use Prooph\EventStore\WriteResult;
Expand Down Expand Up @@ -84,22 +84,22 @@ protected function inspectResponse(ProtobufMessage $response): InspectionResult
case OperationResult::CommitTimeout:
return new InspectionResult(InspectionDecision::retry(), 'CommitTimeout');
case OperationResult::WrongExpectedVersion:
$this->fail(new WrongExpectedVersionException(\sprintf(
$this->fail(new WrongExpectedVersion(\sprintf(
'Commit transaction failed due to WrongExpectedVersion. Transaction id: \'%s\'',
$this->transactionId
)));

return new InspectionResult(InspectionDecision::endOperation(), 'WrongExpectedVersion');
case OperationResult::StreamDeleted:
$this->fail(new StreamDeletedException());
$this->fail(new StreamDeleted());

return new InspectionResult(InspectionDecision::endOperation(), 'StreamDeleted');
case OperationResult::InvalidTransaction:
$this->fail(new InvalidTransactionException());
$this->fail(new InvalidTransaction());

return new InspectionResult(InspectionDecision::endOperation(), 'InvalidTransaction');
case OperationResult::AccessDenied:
$exception = new AccessDeniedException('Write access denied');
$exception = new AccessDenied('Write access denied');
$this->fail($exception);

return new InspectionResult(InspectionDecision::endOperation(), 'AccessDenied');
Expand Down
8 changes: 4 additions & 4 deletions src/ClientOperations/ConditionalAppendToStreamOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use Prooph\EventStore\ConditionalWriteResult;
use Prooph\EventStore\ConditionalWriteStatus;
use Prooph\EventStore\EventData;
use Prooph\EventStore\Exception\AccessDeniedException;
use Prooph\EventStore\Exception\InvalidTransactionException;
use Prooph\EventStore\Exception\AccessDenied;
use Prooph\EventStore\Exception\InvalidTransaction;
use Prooph\EventStore\Exception\UnexpectedOperationResult;
use Prooph\EventStore\Position;
use Prooph\EventStore\UserCredentials;
Expand Down Expand Up @@ -106,12 +106,12 @@ protected function inspectResponse(ProtobufMessage $response): InspectionResult

return new InspectionResult(InspectionDecision::endOperation(), 'StreamDeleted');
case OperationResult::InvalidTransaction:
$exception = new InvalidTransactionException();
$exception = new InvalidTransaction();
$this->fail($exception);

return new InspectionResult(InspectionDecision::endOperation(), 'InvalidTransaction');
case OperationResult::AccessDenied:
$exception = AccessDeniedException::toStream($this->stream);
$exception = AccessDenied::toStream($this->stream);
$this->fail($exception);

return new InspectionResult(InspectionDecision::endOperation(), 'AccessDenied');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
use Amp\Deferred;
use Prooph\EventStore\EventId;
use Prooph\EventStore\EventStoreSubscription;
use Prooph\EventStore\Exception\AccessDeniedException;
use Prooph\EventStore\Exception\AccessDenied;
use Prooph\EventStore\Exception\InvalidArgumentException;
use Prooph\EventStore\Exception\MaximumSubscribersReachedException;
use Prooph\EventStore\Exception\PersistentSubscriptionDeletedException;
use Prooph\EventStore\Exception\MaximumSubscribersReached;
use Prooph\EventStore\Exception\PersistentSubscriptionDeleted;
use Prooph\EventStore\Internal\ConnectToPersistentSubscriptions;
use Prooph\EventStore\Internal\PersistentEventStoreSubscription;
use Prooph\EventStore\PersistentSubscriptionNakEventAction;
Expand Down Expand Up @@ -132,7 +132,7 @@ protected function preInspectPackage(TcpPackage $package): ?InspectionResult
$message->parseFromString($package->data());

if ($message->getReason() === SubscriptionDropReasonMessage::AccessDenied) {
$this->dropSubscription(SubscriptionDropReason::accessDenied(), new AccessDeniedException('You do not have access to the stream'));
$this->dropSubscription(SubscriptionDropReason::accessDenied(), new AccessDenied('You do not have access to the stream'));

return new InspectionResult(InspectionDecision::endOperation(), 'SubscriptionDropped');
}
Expand All @@ -144,13 +144,13 @@ protected function preInspectPackage(TcpPackage $package): ?InspectionResult
}

if ($message->getReason() === SubscriptionDropReasonMessage::PersistentSubscriptionDeleted) {
$this->dropSubscription(SubscriptionDropReason::persistentSubscriptionDeleted(), new PersistentSubscriptionDeletedException());
$this->dropSubscription(SubscriptionDropReason::persistentSubscriptionDeleted(), new PersistentSubscriptionDeleted());

return new InspectionResult(InspectionDecision::endOperation(), 'SubscriptionDropped');
}

if ($message->getReason() === SubscriptionDropReasonMessage::SubscriberMaxCountReached) {
$this->dropSubscription(SubscriptionDropReason::maxSubscribersReached(), new MaximumSubscribersReachedException());
$this->dropSubscription(SubscriptionDropReason::maxSubscribersReached(), new MaximumSubscribersReached());

return new InspectionResult(InspectionDecision::endOperation(), 'SubscriptionDropped');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Amp\Deferred;
use Prooph\EventStore\Common\SystemConsumerStrategies;
use Prooph\EventStore\Exception\AccessDeniedException;
use Prooph\EventStore\Exception\AccessDenied;
use Prooph\EventStore\Exception\InvalidOperationException;
use Prooph\EventStore\Exception\UnexpectedOperationResult;
use Prooph\EventStore\Internal\PersistentSubscriptionCreateResult;
Expand Down Expand Up @@ -105,7 +105,7 @@ protected function inspectResponse(ProtobufMessage $response): InspectionResult

return new InspectionResult(InspectionDecision::endOperation(), 'Fail');
case CreatePersistentSubscriptionResult::AccessDenied:
$this->fail(AccessDeniedException::toStream($this->stream));
$this->fail(AccessDenied::toStream($this->stream));

return new InspectionResult(InspectionDecision::endOperation(), 'AccessDenied');
case CreatePersistentSubscriptionResult::AlreadyExists:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Prooph\EventStoreClient\ClientOperations;

use Amp\Deferred;
use Prooph\EventStore\Exception\AccessDeniedException;
use Prooph\EventStore\Exception\AccessDenied;
use Prooph\EventStore\Exception\InvalidOperationException;
use Prooph\EventStore\Exception\UnexpectedOperationResult;
use Prooph\EventStore\Internal\PersistentSubscriptionDeleteResult;
Expand Down Expand Up @@ -85,7 +85,7 @@ protected function inspectResponse(ProtobufMessage $response): InspectionResult

return new InspectionResult(InspectionDecision::endOperation(), 'Fail');
case DeletePersistentSubscriptionResult::AccessDenied:
$this->fail(AccessDeniedException::toStream($this->stream));
$this->fail(AccessDenied::toStream($this->stream));

return new InspectionResult(InspectionDecision::endOperation(), 'AccessDenied');
case DeletePersistentSubscriptionResult::DoesNotExist:
Expand Down
16 changes: 8 additions & 8 deletions src/ClientOperations/DeleteStreamOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

use Amp\Deferred;
use Prooph\EventStore\DeleteResult;
use Prooph\EventStore\Exception\AccessDeniedException;
use Prooph\EventStore\Exception\InvalidTransactionException;
use Prooph\EventStore\Exception\StreamDeletedException;
use Prooph\EventStore\Exception\AccessDenied;
use Prooph\EventStore\Exception\InvalidTransaction;
use Prooph\EventStore\Exception\StreamDeleted;
use Prooph\EventStore\Exception\UnexpectedOperationResult;
use Prooph\EventStore\Exception\WrongExpectedVersionException;
use Prooph\EventStore\Exception\WrongExpectedVersion;
use Prooph\EventStore\Position;
use Prooph\EventStore\UserCredentials;
use Prooph\EventStoreClient\Messages\ClientMessages\DeleteStream;
Expand Down Expand Up @@ -94,24 +94,24 @@ public function inspectResponse(ProtobufMessage $response): InspectionResult
case OperationResult::ForwardTimeout:
return new InspectionResult(InspectionDecision::retry(), 'ForwardTimeout');
case OperationResult::WrongExpectedVersion:
$this->fail(WrongExpectedVersionException::with(
$this->fail(WrongExpectedVersion::with(
$this->stream,
$this->expectedVersion
));

return new InspectionResult(InspectionDecision::endOperation(), 'WrongExpectedVersion');
case OperationResult::StreamDeleted:
$exception = StreamDeletedException::with($this->stream);
$exception = StreamDeleted::with($this->stream);
$this->fail($exception);

return new InspectionResult(InspectionDecision::endOperation(), 'StreamDeleted');
case OperationResult::InvalidTransaction:
$exception = new InvalidTransactionException();
$exception = new InvalidTransaction();
$this->fail($exception);

return new InspectionResult(InspectionDecision::endOperation(), 'InvalidTransaction');
case OperationResult::AccessDenied:
$exception = AccessDeniedException::toStream($this->stream);
$exception = AccessDenied::toStream($this->stream);
$this->fail($exception);

return new InspectionResult(InspectionDecision::endOperation(), 'AccessDenied');
Expand Down
4 changes: 2 additions & 2 deletions src/ClientOperations/ReadAllEventsBackwardOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Amp\Deferred;
use Prooph\EventStore\AllEventsSlice;
use Prooph\EventStore\Exception\AccessDeniedException;
use Prooph\EventStore\Exception\AccessDenied;
use Prooph\EventStore\Exception\ServerError;
use Prooph\EventStore\Position;
use Prooph\EventStore\ReadDirection;
Expand Down Expand Up @@ -94,7 +94,7 @@ protected function inspectResponse(ProtobufMessage $response): InspectionResult
return new InspectionResult(InspectionDecision::endOperation(), 'Error');
case
ReadAllResult::AccessDenied:
$this->fail(AccessDeniedException::toAllStream());
$this->fail(AccessDenied::toAllStream());

return new InspectionResult(InspectionDecision::endOperation(), 'AccessDenied');
default:
Expand Down
4 changes: 2 additions & 2 deletions src/ClientOperations/ReadAllEventsForwardOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Amp\Deferred;
use Prooph\EventStore\AllEventsSlice;
use Prooph\EventStore\Exception\AccessDeniedException;
use Prooph\EventStore\Exception\AccessDenied;
use Prooph\EventStore\Exception\ServerError;
use Prooph\EventStore\Position;
use Prooph\EventStore\ReadDirection;
Expand Down Expand Up @@ -94,7 +94,7 @@ protected function inspectResponse(ProtobufMessage $response): InspectionResult

return new InspectionResult(InspectionDecision::endOperation(), 'Error');
case ReadAllResult::AccessDenied:
$this->fail(AccessDeniedException::toAllStream());
$this->fail(AccessDenied::toAllStream());

return new InspectionResult(InspectionDecision::endOperation(), 'AccessDenied');
default:
Expand Down
4 changes: 2 additions & 2 deletions src/ClientOperations/ReadEventOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Amp\Deferred;
use Prooph\EventStore\EventReadResult;
use Prooph\EventStore\EventReadStatus;
use Prooph\EventStore\Exception\AccessDeniedException;
use Prooph\EventStore\Exception\AccessDenied;
use Prooph\EventStore\Exception\ServerError;
use Prooph\EventStore\ResolvedEvent;
use Prooph\EventStore\UserCredentials;
Expand Down Expand Up @@ -103,7 +103,7 @@ protected function inspectResponse(ProtobufMessage $response): InspectionResult

return new InspectionResult(InspectionDecision::endOperation(), 'Error');
case ReadEventResult::AccessDenied:
$this->fail(AccessDeniedException::toStream($this->stream));
$this->fail(AccessDenied::toStream($this->stream));

return new InspectionResult(InspectionDecision::endOperation(), 'AccessDenied');
default:
Expand Down
Loading

0 comments on commit 1fb9d87

Please sign in to comment.