Skip to content

Commit 5a6a7fc

Browse files
authored
Merge pull request #30 from M6Web/doc/error-management
Add more details about error management
2 parents 0b1e9f7 + 33456b5 commit 5a6a7fc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,22 @@ function waitException(Tornado\EventLoop $eventLoop)
193193
}
194194
```
195195

196+
When using [`EventLoop::async`](src/EventLoop.php),
197+
all exceptions thrown inside the generator will reject the returned [`Promise`](src/Promise.php).
198+
In case of a background computing you may ignore this [`Promise`](src/Promise.php) and not `yield` nor wait it,
199+
but *Tornado* will still catch thrown exceptions to prevent to miss them.
200+
By design, an ignored rejected [`Promise`](src/Promise.php) will throw its exception during its destruction.
201+
It means that if you **really** want to ignore all exceptions (really?),
202+
you have to catch and ignore them **explicitly** in your code.
203+
```php
204+
$ignoredPromise = $eventLoop->async((function() {
205+
try {
206+
yield from throwingGenerator();
207+
} catch(\Throwable $throwable) {
208+
// I want to ignore all exceptions for this function
209+
}
210+
})());
211+
```
196212

197213
## FAQ
198214

0 commit comments

Comments
 (0)