@@ -96,12 +96,15 @@ $delayed = new ConnectionManagerDelayed($connector, 0.5, $loop);
9696
9797### Reject
9898
99- The ` ConnectionManagerReject(? string $reason) ` simply rejects every single connection attempt.
99+ The ` ConnectionManagerReject(null| string|callable $reason) ` simply rejects every single connection attempt.
100100This is particularly useful for the below [ ` ConnectionManagerSelective ` ] ( #selective ) to reject connection attempts
101101to only certain destinations (for example blocking advertisements or harmful sites).
102102
103- The constructor accepts an optional rejection reason which will be used for the
104- ` Exception ` instance that is used to reject the resulting promise.
103+ The constructor accepts an optional rejection reason which will be used for
104+ rejecting the resulting promise.
105+
106+ You can explicitly pass a ` string ` value which will be used as the message for
107+ the ` Exception ` instance:
105108
106109``` php
107110$connector = new ConnectionManagerReject('Blocked');
@@ -111,6 +114,19 @@ $connector->connect('www.google.com:80')->then(null, function ($e) {
111114});
112115```
113116
117+ You can explicitly pass a ` callable ` value which will be used to either
118+ ` throw ` or ` return ` a custom ` Exception ` instance:
119+
120+ ``` php
121+ $connector = new ConnectionManagerReject(function ($uri) {
122+ throw new RuntimeException($uri . ' blocked');
123+ });
124+ $connector->connect('www.google.com:80')->then(null, function ($e) {
125+ assert($e instanceof \RuntimeException);
126+ assert($e->getMessage() === 'www.google.com:80 blocked');
127+ });
128+ ```
129+
114130### Swappable
115131
116132The ` ConnectionManagerSwappable($connector) ` is a simple decorator for other ` ConnectionManager ` s to
0 commit comments