Skip to content

Commit

Permalink
Throw EntityNotFound exception hwen getting reference
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk committed Dec 13, 2024
1 parent 1fa321d commit 8c48afb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public function findFormReference(string $field, Form $form): ?object
/**
* @return T
* @throws BadMethodCallException
* @throws EntityNotFoundException
*/
public function getFormReference(string $field, Form $form): object
{
Expand All @@ -292,7 +293,12 @@ public function getFormReference(string $field, Form $form): object
/** @var string|null */
$id = $form->getHttpData(Form::DataLine, $field) ?: null;

return $this->getById($id);
try {
return $this->getById($id);

} catch (NoResultException $e) {
throw EntityNotFoundException::fromField($field, $id, $e);
}
}


Expand Down

0 comments on commit 8c48afb

Please sign in to comment.