3 namespace Drupal\libraries\ExternalLibrary\Exception;
5 use Drupal\libraries\ExternalLibrary\Utility\DependencyAccessorTrait;
6 use Drupal\libraries\ExternalLibrary\LibraryInterface;
7 use Drupal\libraries\ExternalLibrary\Utility\LibraryAccessorTrait;
8 use Drupal\libraries\ExternalLibrary\Utility\LibraryAccessorInterface;
11 * Provides an exception for an invalid library exception.
13 class InvalidLibraryDependencyException extends \UnexpectedValueException implements LibraryAccessorInterface {
15 use LibraryAccessorTrait;
16 use DependencyAccessorTrait;
19 * Constructs a library exception.
21 * @param \Drupal\libraries\ExternalLibrary\LibraryInterface $library
22 * The library with the invalid dependency.
23 * @param \Drupal\libraries\ExternalLibrary\LibraryInterface $dependency
25 * @param string $message
26 * (optional) The exception message.
28 * (optional) The error code.
29 * @param \Exception $previous
30 * (optional) The previous exception.
32 public function __construct(
33 LibraryInterface $library,
34 LibraryInterface $dependency,
37 \Exception $previous = NULL
39 $this->library = $library;
40 $this->dependency = $dependency;
41 $message = $message ?: "The library '{$this->library->getId()}' cannot depend on the library '{$this->dependency->getId()}'.";
42 parent::__construct($message, $code, $previous);