blob: 32cf3d9959c0f2fd6d8fe1da8a3333038992f401 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
<?php
declare(strict_types=1);
namespace OpenTelemetry\SDK\Common\Future;
use Closure;
use Throwable;
final class ErrorFuture implements FutureInterface
{
private Throwable $throwable;
public function __construct(Throwable $throwable)
{
$this->throwable = $throwable;
}
public function await()
{
throw $this->throwable;
}
public function map(Closure $closure): FutureInterface
{
return $this;
}
public function catch(Closure $closure): FutureInterface
{
$c = $closure;
unset($closure);
try {
return new CompletedFuture($c($this->throwable));
} catch (Throwable $e) {
return new ErrorFuture($e);
}
}
}
|