Skip to content

Instantly share code, notes, and snippets.

@mdzwigala
Last active December 8, 2020 11:52
Show Gist options
  • Save mdzwigala/4271a52492e5cc0c5a657f3828d04478 to your computer and use it in GitHub Desktop.
Save mdzwigala/4271a52492e5cc0c5a657f3828d04478 to your computer and use it in GitHub Desktop.
ADR-EXAMPLE\Infrastructurer\DataValidationException
<?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