@@ -174,6 +174,12 @@ $client->imageCreate('clue/streamripper')->then(
174174 },
175175 function ($error) {
176176 // an error occurred (possibly after receiving *some* elements)
177+
178+ if ($error instanceof Io\JsonProgressException) {
179+ // a progress message (usually the last) contains an error message
180+ } else {
181+ // any other error, like invalid request etc.
182+ }
177183 }
178184);
179185```
@@ -199,6 +205,8 @@ The resulting stream will emit the following events:
199205
200206* ` progress ` : for * each* element in the update stream
201207* ` error ` : once if an error occurs, will close() stream then
208+ * Will emit an [ ` Io\JsonProgressException ` ] ( #jsonprogressexception ) if an individual progress message contains an error message
209+ * Any other ` Exception ` in case of an transport error, like invalid request etc.
202210* ` close ` : once the stream ends (either finished or after "error")
203211
204212Please note that the resulting stream does not emit any "data" events, so
@@ -218,6 +226,13 @@ $stream->on('close', function () {
218226
219227See also the [ pull example] ( examples/pull.php ) and the [ push example] ( examples/push.php ) .
220228
229+ ### JsonProgressException
230+
231+ The ` Io\JsonProgressException ` will be thrown by [ JSON streaming] ( #json-streaming )
232+ endpoints if an individual progress message contains an error message.
233+
234+ The ` getData() ` method can be used to obtain the progress message.
235+
221236## Install
222237
223238The recommended way to install this library is [ through composer] ( http://getcomposer.org ) . [ New to composer?] ( http://getcomposer.org/doc/00-intro.md )
0 commit comments