| @@ 18-39 (lines=22) @@ | ||
| 15 | use Tolerance\Operation\Exception\PromiseException; |
|
| 16 | use Tolerance\Operation\ExceptionCatcher\ThrowableCatcherVoter; |
|
| 17 | ||
| 18 | final class RequestServerErrorVoter implements ThrowableCatcherVoter |
|
| 19 | { |
|
| 20 | /** |
|
| 21 | * {@inheritdoc} |
|
| 22 | */ |
|
| 23 | public function shouldCatch(\Exception $e) |
|
| 24 | { |
|
| 25 | return $this->shouldCatchThrowable($e); |
|
| 26 | } |
|
| 27 | ||
| 28 | /** |
|
| 29 | * {@inheritdoc} |
|
| 30 | */ |
|
| 31 | public function shouldCatchThrowable($throwable) |
|
| 32 | { |
|
| 33 | return !$throwable instanceof PromiseException |
|
| 34 | || $throwable->isRejected() |
|
| 35 | || !$throwable->getValue() instanceof Response |
|
| 36 | || $throwable->getValue()->getStatusCode() >= 500 |
|
| 37 | ; |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||
| @@ 18-39 (lines=22) @@ | ||
| 15 | use Tolerance\Operation\Exception\PromiseException; |
|
| 16 | use Tolerance\Operation\ExceptionCatcher\ThrowableCatcherVoter; |
|
| 17 | ||
| 18 | final class RequestServerErrorVoter implements ThrowableCatcherVoter |
|
| 19 | { |
|
| 20 | /** |
|
| 21 | * {@inheritdoc} |
|
| 22 | */ |
|
| 23 | public function shouldCatch(\Exception $e) |
|
| 24 | { |
|
| 25 | return $this->shouldCatchThrowable($e); |
|
| 26 | } |
|
| 27 | ||
| 28 | /** |
|
| 29 | * {@inheritdoc} |
|
| 30 | */ |
|
| 31 | public function shouldCatchThrowable($throwable) |
|
| 32 | { |
|
| 33 | return !$throwable instanceof PromiseException |
|
| 34 | || $throwable->isRejected() |
|
| 35 | || !$throwable->getValue() instanceof ResponseInterface |
|
| 36 | || $throwable->getValue()->getStatusCode() >= 500 |
|
| 37 | ; |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||