You are here

protected function OEmbedResourceConstraintValidator::handleException in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media/src/Plugin/Validation/Constraint/OEmbedResourceConstraintValidator.php \Drupal\media\Plugin\Validation\Constraint\OEmbedResourceConstraintValidator::handleException()

Handles exceptions that occur during validation.

Parameters

\Exception $e: The caught exception.

string $error_message: (optional) The error message to set as a constraint violation.

1 call to OEmbedResourceConstraintValidator::handleException()
OEmbedResourceConstraintValidator::validate in core/modules/media/src/Plugin/Validation/Constraint/OEmbedResourceConstraintValidator.php
Checks if the passed value is valid.

File

core/modules/media/src/Plugin/Validation/Constraint/OEmbedResourceConstraintValidator.php, line 132

Class

OEmbedResourceConstraintValidator
Validates oEmbed resource URLs.

Namespace

Drupal\media\Plugin\Validation\Constraint

Code

protected function handleException(\Exception $e, $error_message = NULL) {
  if ($error_message) {
    $this->context
      ->addViolation($error_message);
  }

  // The oEmbed system makes heavy use of exception wrapping, so log the
  // entire exception chain to help with troubleshooting.
  do {

    // @todo If $e is a ProviderException or ResourceException, log additional
    // debugging information contained in those exceptions in
    // https://www.drupal.org/project/drupal/issues/2972846.
    $this->logger
      ->error($e
      ->getMessage());
    $e = $e
      ->getPrevious();
  } while ($e);
}