blob: d4d958eb05018a24fe4798f19b2557636ebf6785 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
<?php
declare(strict_types=1);
namespace Nsfisis\Albatross\Exceptions;
use RuntimeException;
use Throwable;
final class EntityValidationException extends RuntimeException
{
/**
* @param array<string, string> $errors
*/
public function __construct(
string $message = '',
int $code = 0,
?Throwable $previous = null,
private readonly array $errors = [],
) {
parent::__construct($message, $code, $previous);
}
/**
* @return array<string, string>
*/
public function toFormErrors(): array
{
if (count($this->errors) === 0) {
return ['general' => $this->getMessage()];
} else {
return $this->errors;
}
}
}
|