55
66use Amp \Promise ;
77use ScriptFUSION \Porter \Cache \CacheUnavailableException ;
8+ use ScriptFUSION \Porter \Connector \Recoverable \RecoverableException ;
89use ScriptFUSION \Porter \Connector \Recoverable \RecoverableExceptionHandler ;
910use ScriptFUSION \Porter \Connector \Recoverable \StatelessRecoverableExceptionHandler ;
1011
@@ -27,21 +28,21 @@ final class ImportConnector implements ConnectorWrapper
2728 *
2829 * @var RecoverableExceptionHandler
2930 */
30- private $ userReh ;
31+ private $ userExceptionHandler ;
3132
3233 /**
3334 * Resource-defined exception handler called when a recoverable exception is thrown by Connector::fetch().
3435 *
3536 * @var RecoverableExceptionHandler
3637 */
37- private $ resourceReh ;
38+ private $ resourceExceptionHandler ;
3839
3940 private $ maxFetchAttempts ;
4041
4142 /**
4243 * @param Connector|AsyncConnector $connector Wrapped connector.
4344 * @param ConnectionContext $connectionContext Connection context.
44- * @param RecoverableExceptionHandler $recoverableExceptionHandler
45+ * @param RecoverableExceptionHandler $recoverableExceptionHandler User's recoverable exception handler.
4546 * @param int $maxFetchAttempts
4647 */
4748 public function __construct (
@@ -56,7 +57,7 @@ public function __construct(
5657
5758 $ this ->connector = clone $ connector ;
5859 $ this ->connectionContext = $ connectionContext ;
59- $ this ->userReh = $ recoverableExceptionHandler ;
60+ $ this ->userExceptionHandler = $ recoverableExceptionHandler ;
6061 $ this ->maxFetchAttempts = $ maxFetchAttempts ;
6162 }
6263
@@ -92,17 +93,17 @@ private function createExceptionHandler(): \Closure
9293
9394 return function (\Exception $ exception ) use (&$ userHandlerCloned , &$ resourceHandlerCloned ): void {
9495 // Throw exception instead of retrying, if unrecoverable.
95- if (!$ exception instanceof RecoverableConnectorException ) {
96+ if (!$ exception instanceof RecoverableException ) {
9697 throw $ exception ;
9798 }
9899
99100 // Call resource's exception handler, if defined.
100- if ($ this ->resourceReh ) {
101- self ::invokeHandler ($ this ->resourceReh , $ exception , $ resourceHandlerCloned );
101+ if ($ this ->resourceExceptionHandler ) {
102+ self ::invokeHandler ($ this ->resourceExceptionHandler , $ exception , $ resourceHandlerCloned );
102103 }
103104
104105 // Call user's exception handler.
105- self ::invokeHandler ($ this ->userReh , $ exception , $ userHandlerCloned );
106+ self ::invokeHandler ($ this ->userExceptionHandler , $ exception , $ userHandlerCloned );
106107 };
107108 }
108109
@@ -163,10 +164,10 @@ public function findBaseConnector()
163164 */
164165 public function setRecoverableExceptionHandler (RecoverableExceptionHandler $ recoverableExceptionHandler ): void
165166 {
166- if ($ this ->resourceReh !== null ) {
167+ if ($ this ->resourceExceptionHandler !== null ) {
167168 throw new \LogicException ('Cannot set resource \'s recoverable exception handler: already set! ' );
168169 }
169170
170- $ this ->resourceReh = $ recoverableExceptionHandler ;
171+ $ this ->resourceExceptionHandler = $ recoverableExceptionHandler ;
171172 }
172173}
0 commit comments