From deacd0dfc195bca41af631114804d29937337cd8 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 17 Jan 2024 02:11:31 +0900 Subject: . --- .../src/Exceptions/EntityValidationException.php | 35 ++++++++++++++++++++++ .../app/src/Exceptions/InvalidSqlException.php | 11 +++++++ 2 files changed, 46 insertions(+) create mode 100644 services/app/src/Exceptions/EntityValidationException.php create mode 100644 services/app/src/Exceptions/InvalidSqlException.php (limited to 'services/app/src/Exceptions') diff --git a/services/app/src/Exceptions/EntityValidationException.php b/services/app/src/Exceptions/EntityValidationException.php new file mode 100644 index 0000000..d4d958e --- /dev/null +++ b/services/app/src/Exceptions/EntityValidationException.php @@ -0,0 +1,35 @@ + $errors + */ + public function __construct( + string $message = '', + int $code = 0, + ?Throwable $previous = null, + private readonly array $errors = [], + ) { + parent::__construct($message, $code, $previous); + } + + /** + * @return array + */ + public function toFormErrors(): array + { + if (count($this->errors) === 0) { + return ['general' => $this->getMessage()]; + } else { + return $this->errors; + } + } +} diff --git a/services/app/src/Exceptions/InvalidSqlException.php b/services/app/src/Exceptions/InvalidSqlException.php new file mode 100644 index 0000000..fa53ca1 --- /dev/null +++ b/services/app/src/Exceptions/InvalidSqlException.php @@ -0,0 +1,11 @@ +