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

@ -29,10 +29,8 @@ Flight::route('/do_upload', [$uploadController, 'upload']);
Flight::map('error', function (\Throwable $ex) {
$code = 500;
if ($ex instanceof InvalidKeyException) {
$code = 401;
} elseif ($ex instanceof InvalidHashException) {
$code = 412;
if ($ex->getCode()) {
$code = $ex->getCode();
}
/** @var Response $response */
$response = Flight::response()->status($code);