You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -131,15 +133,17 @@ Please see the following section about [promises](#promises) for more details.
131
133
132
134
Sending requests is async (non-blocking), so you can actually send multiple requests in parallel.
133
135
Docker will respond to each request with a response message, the order is not guaranteed.
134
-
Sending requests uses a [Promise](https://github.com/reactphp/promise)-based interface that makes it easy to react to when a request is fulfilled (i.e. either successfully resolved or rejected with an error):
136
+
Sending requests uses a [Promise](https://github.com/reactphp/promise)-based
137
+
interface that makes it easy to react to when a command is completed
138
+
(i.e. either successfully fulfilled or rejected with an error):
135
139
136
140
```php
137
141
$client->version()->then(
138
142
function ($result) {
139
143
var_dump('Result received', $result);
140
144
},
141
-
function (Exception $error) {
142
-
var_dump('There was an error', $error->getMessage());
145
+
function (Exception $e) {
146
+
echo 'Error: ' . $e->getMessage() . PHP_EOL;
143
147
}
144
148
});
145
149
```
@@ -214,10 +218,16 @@ the normal stream events:
214
218
215
219
```php
216
220
$stream = $client->execStartStream($exec, $tty);
221
+
217
222
$stream->on('data', function ($data) {
218
223
// data will be emitted in multiple chunk
219
224
echo $data;
220
225
});
226
+
227
+
$stream->on('error', function (Exception $e) {
228
+
echo 'Error: ' . $e->getMessage() . PHP_EOL;
229
+
});
230
+
221
231
$stream->on('close', function () {
222
232
// the stream just ended, this could(?) be a good thing
223
233
echo 'Ended' . PHP_EOL;
@@ -233,9 +243,11 @@ Also note that this option has no effect if you execute with a TTY.
0 commit comments