-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #262 from clue-labs/unhandled-previous
Include previous exceptions when reporting unhandled promise rejections
- Loading branch information
Showing
5 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/FunctionRejectTestShouldReportUnhandledWithPreviousExceptions.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--TEST-- | ||
Calling reject() without any handlers should report unhandled rejection with all previous exceptions | ||
--INI-- | ||
# suppress legacy PHPUnit 7 warning for Xdebug 3 | ||
xdebug.default_enable= | ||
--FILE-- | ||
<?php | ||
|
||
use function React\Promise\reject; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
reject(new RuntimeException('foo', 42, new \OverflowException('bar', 1000, new \InvalidArgumentException()))); | ||
|
||
?> | ||
--EXPECTF-- | ||
Unhandled promise rejection with InvalidArgumentException in %s:%d | ||
Stack trace: | ||
#0 %A{main} | ||
|
||
Next OverflowException: bar in %s:%d | ||
Stack trace: | ||
#0 %A{main} | ||
|
||
Next RuntimeException: foo in %s:%d | ||
Stack trace: | ||
#0 %A{main} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...etRejectionHandlerThatThrowsShouldTerminateProgramForUnhandledWithPreviousExceptions.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--TEST-- | ||
The callback given to set_rejection_handler() should not throw an exception or the program should terminate for unhandled rejection with all previous exceptions | ||
--INI-- | ||
# suppress legacy PHPUnit 7 warning for Xdebug 3 | ||
xdebug.default_enable= | ||
--FILE-- | ||
<?php | ||
|
||
use function React\Promise\reject; | ||
use function React\Promise\set_rejection_handler; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
set_rejection_handler(function (Throwable $e): void { | ||
throw new RuntimeException('foo', 42, new \OverflowException('bar', 1000, new \InvalidArgumentException())); | ||
}); | ||
|
||
reject(new RuntimeException('foo')); | ||
|
||
echo 'NEVER'; | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Uncaught InvalidArgumentException from unhandled promise rejection handler in %s:%d | ||
Stack trace: | ||
#0 %A{main} | ||
|
||
Next OverflowException: bar in %s:%d | ||
Stack trace: | ||
#0 %A{main} | ||
|
||
Next RuntimeException: foo in %s:%d | ||
Stack trace: | ||
#0 %A{main} |