function ValidationResult::createErrorFromThrowable
Creates an error ValidationResult object from a throwable.
Parameters
\Throwable $throwable: The throwable.
\Drupal\Core\StringTranslation\TranslatableMarkup|null $summary: The errors summary.
Return value
static
3 calls to ValidationResult::createErrorFromThrowable()
- PreOperationStageEvent::addErrorFromThrowable in core/
modules/ package_manager/ src/ Event/ PreOperationStageEvent.php - Convenience method, adds an error validation result from a throwable.
- StatusCheckTraitTest::testNoErrorIfPathsToExcludeCannotBeCollected in core/
modules/ package_manager/ tests/ src/ Kernel/ StatusCheckTraitTest.php - Tests that any error will be added to the status check event.
- ValidationResultTest::testMessagesMustBeTranslatable in core/
modules/ package_manager/ tests/ src/ Unit/ ValidationResultTest.php - Tests that the messages are asserted to be translatable.
File
-
core/
modules/ package_manager/ src/ ValidationResult.php, line 75
Class
- ValidationResult
- A value object to contain the results of a validation.
Namespace
Drupal\package_managerCode
public static function createErrorFromThrowable(\Throwable $throwable, ?TranslatableMarkup $summary = NULL) : static {
// All Composer Stager exceptions are translatable.
$is_translatable = $throwable instanceof ExceptionInterface;
$message = $is_translatable ? $throwable->getTranslatableMessage() : $throwable->getMessage();
return new static(SystemManager::REQUIREMENT_ERROR, [
$message,
], $summary, $is_translatable);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.