mirror of
https://github.com/danog/amp.git
synced 2024-11-27 04:24:42 +01:00
Fail promise timeout() operations using TimeoutException
This commit is contained in:
parent
094899a74b
commit
705c57483b
5
lib/TimeoutException.php
Normal file
5
lib/TimeoutException.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Amp;
|
||||||
|
|
||||||
|
class TimeoutException extends \RuntimeException {}
|
@ -720,7 +720,7 @@ function timeout(Promise $promise, $msTimeout) {
|
|||||||
$promisor = new Deferred;
|
$promisor = new Deferred;
|
||||||
$watcherId = once(function () use ($promisor, &$resolved) {
|
$watcherId = once(function () use ($promisor, &$resolved) {
|
||||||
$resolved = true;
|
$resolved = true;
|
||||||
$promisor->fail(new \RuntimeException(
|
$promisor->fail(new TimeoutException(
|
||||||
"Promise resolution timed out"
|
"Promise resolution timed out"
|
||||||
));
|
));
|
||||||
}, $msTimeout);
|
}, $msTimeout);
|
||||||
|
Loading…
Reference in New Issue
Block a user