1
0
Fork 0
mirror of https://codeberg.org/demostf/api.git synced 2026-06-03 18:04:08 +02:00

proper error response for not found demos

This commit is contained in:
Robin Appelman 2020-12-09 22:47:28 +01:00
commit 202d11fcc9
7 changed files with 61 additions and 9 deletions

View file

@ -7,6 +7,7 @@ namespace Demostf\API\Controllers;
use Demostf\API\Demo\DemoStore;
use Demostf\API\Error\InvalidHashException;
use Demostf\API\Error\InvalidKeyException;
use Demostf\API\Error\NotFoundException;
use Demostf\API\Providers\ChatProvider;
use Demostf\API\Providers\DemoListProvider;
use Demostf\API\Providers\DemoProvider;
@ -38,7 +39,12 @@ class DemoController extends BaseController {
}
public function get(string $id): void {
$this->json($this->demoProvider->get(\intval($id, 10)));
$demo = $this->demoProvider->get(\intval($id, 10));
if ($demo === null) {
throw new NotFoundException("requested demo not found");
} else {
$this->json($demo);
}
}
/**