ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
Failure.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27final class Failure
28{
29 public static function of(\Throwable $e): \Exception
30 {
31 // is_int(): a PDOException carries its SQLSTATE as string, and '42S02' compares as 4xx
32 $code = $e->getCode();
33 if ($e instanceof \Exception && is_int($code) && $code >= 400 && $code < 500) {
34 return $e;
35 }
36
37 return new \RuntimeException('The activity could not be performed.', 500, $e);
38 }
39}
Error of maybePerformAs(): 4xx exceptions answer the call and pass unchanged, anything else is a defe...
Definition: Failure.php:28
static of(\Throwable $e)
Definition: Failure.php:29