-
-
Save mdzwigala/4271a52492e5cc0c5a657f3828d04478 to your computer and use it in GitHub Desktop.
ADR-EXAMPLE\Infrastructurer\DataValidationException
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Infrastructure\Exception; | |
use Symfony\Component\HttpFoundation\Response; | |
use Symfony\Component\HttpKernel\Exception\HttpException; | |
final class DataValidationException extends HttpException | |
{ | |
private array $errors; | |
public function __construct(array $errorMessages) | |
{ | |
parent::__construct(Response::HTTP_UNPROCESSABLE_ENTITY, 'Data Validation Exception: ' . json_encode($errorMessages)); | |
$this->errors = $errorMessages; | |
} | |
public function getErrors(): array | |
{ | |
return $this->errors; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment