Skip to content

Commit

Permalink
Improve the error messages for batch processes
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianallgeier committed Dec 13, 2024
1 parent 131bc94 commit 0a21d42
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Cms/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function delete(array $ids): void

if ($model instanceof File === false) {
throw new NotFoundException(
key: 'file.notFound'
key: 'file.undefined'
);
}

Expand All @@ -126,6 +126,7 @@ public function delete(array $ids): void
if ($exceptions !== []) {
throw new Exception(
key: 'file.delete.multiple',
details: $exceptions
);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Cms/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function delete(array $ids): void

if ($model instanceof Page === false) {
throw new NotFoundException(
key: 'page.notFound'
key: 'page.undefined',
);
}

Expand All @@ -151,6 +151,7 @@ public function delete(array $ids): void
if ($exceptions !== []) {
throw new Exception(
key: 'page.delete.multiple',
details: $exceptions
);
}
}
Expand Down
13 changes: 12 additions & 1 deletion src/Exception/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 0a21d42

Please sign in to comment.