Skip to content

Commit

Permalink
Merge pull request #514 from stopfstedt/404_instead_of_500
Browse files Browse the repository at this point in the history
throw 404/not found exceptions instead of 500/server-error if resource cannot be found.
  • Loading branch information
stopfstedt committed Aug 1, 2020
2 parents 8a0449b + 8e82706 commit 51d0ec4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Controller/ApiController.php
Expand Up @@ -161,7 +161,7 @@ public function getCardAction($card_code, Request $request)

$card = $this->getDoctrine()->getRepository(Card::class)->findOneBy(array("code" => $card_code));
if (!$card instanceof CardInterface) {
return $this->createNotFoundException();
throw $this->createNotFoundException();
}

// check the last-modified-since header
Expand Down Expand Up @@ -315,7 +315,7 @@ public function listCardsByPackAction($pack_code, Request $request)

$pack = $this->getDoctrine()->getRepository(Pack::class)->findOneBy(array('code' => $pack_code));
if (!$pack instanceof PackInterface) {
return $this->createNotFoundException();
throw $this->createNotFoundException();
}

$conditions = $this->get(CardsData::class)->syntax("e:$pack_code");
Expand Down Expand Up @@ -402,7 +402,7 @@ public function getDecklistAction($decklist_id, Request $request)
/* @var DecklistInterface $decklist */
$decklist = $this->getDoctrine()->getRepository(Decklist::class)->find($decklist_id);
if (!$decklist instanceof Decklist) {
return $this->createNotFoundException();
throw $this->createNotFoundException();
}

$response->setLastModified($decklist->getDateUpdate());
Expand Down

0 comments on commit 51d0ec4

Please sign in to comment.