From 0a21d42b1d7cd7d236505092e804522559c7dd1c Mon Sep 17 00:00:00 2001 From: Bastian Allgeier Date: Fri, 13 Dec 2024 17:23:53 +0100 Subject: [PATCH] Improve the error messages for batch processes --- src/Cms/Files.php | 3 ++- src/Cms/Pages.php | 3 ++- src/Exception/Exception.php | 13 ++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Cms/Files.php b/src/Cms/Files.php index 0dbf77d6fd..a0abf4c45f 100644 --- a/src/Cms/Files.php +++ b/src/Cms/Files.php @@ -113,7 +113,7 @@ public function delete(array $ids): void if ($model instanceof File === false) { throw new NotFoundException( - key: 'file.notFound' + key: 'file.undefined' ); } @@ -126,6 +126,7 @@ public function delete(array $ids): void if ($exceptions !== []) { throw new Exception( key: 'file.delete.multiple', + details: $exceptions ); } } diff --git a/src/Cms/Pages.php b/src/Cms/Pages.php index f85f95c2b9..bbb1bbc70d 100644 --- a/src/Cms/Pages.php +++ b/src/Cms/Pages.php @@ -138,7 +138,7 @@ public function delete(array $ids): void if ($model instanceof Page === false) { throw new NotFoundException( - key: 'page.notFound' + key: 'page.undefined', ); } @@ -151,6 +151,7 @@ public function delete(array $ids): void if ($exceptions !== []) { throw new Exception( key: 'page.delete.multiple', + details: $exceptions ); } } diff --git a/src/Exception/Exception.php b/src/Exception/Exception.php index 5d5927e752..2b8cbed421 100644 --- a/src/Exception/Exception.php +++ b/src/Exception/Exception.php @@ -172,7 +172,18 @@ final public function getData(): array */ final public function getDetails(): array { - return $this->details; + $details = $this->details; + + foreach ($details as $key => $detail) { + if ($detail instanceof Throwable) { + $details[$key] = [ + 'label' => $key, + 'message' => $detail->getMessage(), + ]; + } + } + + return $details; } /**