0
0
Fork 0
mirror of https://github.com/verdigado/organization_folders.git synced 2024-12-06 11:22:41 +01:00

improved error handling

This commit is contained in:
Jonathan Treffler 2024-11-20 03:07:26 +01:00
parent 9f14ca2179
commit ab378ea223
2 changed files with 19 additions and 8 deletions

View file

@ -32,10 +32,10 @@ class ResourceMemberService {
return $this->mapper->findAll($resourceId);
}
private function handleException(Exception $e): void {
private function handleException(Exception $e, int $id): void {
if ($e instanceof DoesNotExistException ||
$e instanceof MultipleObjectsReturnedException) {
throw new ResourceMemberNotFound($e->getMessage());
throw new ResourceMemberNotFound($id);
} else {
throw $e;
}
@ -45,7 +45,7 @@ class ResourceMemberService {
try {
return $this->mapper->find($id);
} catch (Exception $e) {
$this->handleException($e);
$this->handleException($e, $id);
}
}
@ -96,7 +96,7 @@ class ResourceMemberService {
return $member;
} catch (Exception $e) {
$this->handleException($e);
$this->handleException($e, $id);
}
}
@ -111,7 +111,7 @@ class ResourceMemberService {
return $member;
} catch (Exception $e) {
$this->handleException($e);
$this->handleException($e, $id);
}
}
}