ValidationFailedException.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Messenger\Exception;
  11. use Symfony\Component\Validator\ConstraintViolationListInterface;
  12. /**
  13. * @author Tobias Nyholm <tobias.nyholm@gmail.com>
  14. */
  15. class ValidationFailedException extends RuntimeException
  16. {
  17. private $violations;
  18. private $violatingMessage;
  19. /**
  20. * @param object $violatingMessage
  21. */
  22. public function __construct($violatingMessage, ConstraintViolationListInterface $violations)
  23. {
  24. $this->violatingMessage = $violatingMessage;
  25. $this->violations = $violations;
  26. parent::__construct(sprintf('Message of type "%s" failed validation.', \get_class($this->violatingMessage)));
  27. }
  28. public function getViolatingMessage()
  29. {
  30. return $this->violatingMessage;
  31. }
  32. public function getViolations(): ConstraintViolationListInterface
  33. {
  34. return $this->violations;
  35. }
  36. }