2017-09-20 17:34:20 +02:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
2017-09-20 17:50:00 +02:00
|
|
|
|
2017-09-20 17:34:20 +02:00
|
|
|
use Amp\Loop;
|
|
|
|
|
|
|
|
require_once __DIR__ . "/../../vendor/autoload.php";
|
|
|
|
|
|
|
|
Loop::setErrorHandler(function (\Throwable $e) {
|
|
|
|
echo "error handler -> " . $e->getMessage() . PHP_EOL;
|
|
|
|
});
|
|
|
|
|
|
|
|
try {
|
|
|
|
Loop::run(function () {
|
|
|
|
// Uncaught exceptions in loop callbacks just bubble out of Loop::run()
|
|
|
|
Loop::delay(1000, function () {
|
|
|
|
throw new Exception("force exception");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
echo "continuing normally" . PHP_EOL;
|
|
|
|
} catch (Throwable $loopException) {
|
|
|
|
echo "loop bubbled exception caught -> " . $loopException->getMessage() . PHP_EOL;
|
|
|
|
}
|