mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-25 14:10:28 +01:00
38 lines
822 B
PHP
38 lines
822 B
PHP
<?php
|
|
|
|
namespace Xentral\Modules\Ebay\Exception;
|
|
|
|
use RuntimeException;
|
|
|
|
final class ValidationFailedException extends RuntimeException implements EbayExceptionInterface
|
|
{
|
|
/** @var array $errors */
|
|
private $errors = [];
|
|
|
|
/**
|
|
* @param array $errors
|
|
*
|
|
* @return self
|
|
*/
|
|
public static function fromErrors(array $errors): self
|
|
{
|
|
$errorString = '';
|
|
foreach ($errors as $propertyName => $propertyErrors) {
|
|
$errorString .= implode("\r\n", $propertyErrors);
|
|
}
|
|
|
|
$exception = new self('Validation failed with following errors: ' . "\n\n" . $errorString);
|
|
$exception->errors = $errors;
|
|
|
|
return $exception;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getErrors(): array
|
|
{
|
|
return $this->errors;
|
|
}
|
|
}
|