You are here

protected function OEmbedResourceConstraintValidator::handleException in Drupal 9

Same name and namespace in other branches
  1. 8 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

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);
}