ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\FileUpload\Activities\Failure Class Reference

What the file activities hand to Data\Factory::error() when something failed: the result only takes exceptions, and maybePerformAs() promises to wrap every failure in a result - an \Error from deep inside a legacy service included. More...

+ Collaboration diagram for ILIAS\FileUpload\Activities\Failure:

Static Public Member Functions

static of (\Throwable $e)
 

Detailed Description

What the file activities hand to Data\Factory::error() when something failed: the result only takes exceptions, and maybePerformAs() promises to wrap every failure in a result - an \Error from deep inside a legacy service included.

Only an answer to the request leaves as it is: an exception with a code of the 4xx range, which is how the activities say what was wrong with a call. Everything else is a defect, and its message may carry what a caller must not see - a query, a path in the storage. It is replaced by a generic one and kept as the previous throwable for whoever debugs it.

The code has to be an int: a PDOException carries its SQLSTATE as a string, and ‘'42S22’` compares as being between 400 and 500.

Definition at line 38 of file Failure.php.

Member Function Documentation

◆ of()

static ILIAS\FileUpload\Activities\Failure::of ( \Throwable  $e)
static

Definition at line 40 of file Failure.php.

40 : \Exception
41 {
42 $code = $e->getCode();
43
44 if ($e instanceof \Exception && is_int($code) && $code >= 400 && $code < 500) {
45 return $e;
46 }
47
48 return new \RuntimeException('The activity could not be performed.', 500, $e);
49 }

References Vendor\Package\$e.

Referenced by ILIAS\FileUpload\Activities\FailureTest\testADefectKeepsItsMessageInside(), and ILIAS\FileUpload\Activities\FailureTest\testAnAnswerToTheRequestLeavesAsItIs().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: