Skip to content

Commit

Permalink
Merge pull request #30 from M6Web/doc/error-management
Browse files Browse the repository at this point in the history
Add more details about error management
  • Loading branch information
b-viguier authored Jan 14, 2019
2 parents 0b1e9f7 + 33456b5 commit 5a6a7fc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,22 @@ function waitException(Tornado\EventLoop $eventLoop)
}
```

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

## FAQ

Expand Down

0 comments on commit 5a6a7fc

Please sign in to comment.