mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-04 02:14:06 +02:00
explicit upload errors
This commit is contained in:
parent
2055526cb0
commit
8c80182ab1
3 changed files with 7 additions and 59 deletions
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Demostf\API\Controllers;
|
||||
|
||||
use Demostf\API\Error\InvalidKeyException;
|
||||
use Demostf\API\Providers\UploadProvider;
|
||||
use Exception;
|
||||
use Flight;
|
||||
|
|
@ -31,18 +32,6 @@ class UploadController extends BaseController {
|
|||
}
|
||||
$demoFile = $demo['tmp_name'];
|
||||
|
||||
try {
|
||||
$result = $this->uploadProvider->upload($key, $red, $blu, $name, $demoFile);
|
||||
if ('Invalid key' === $result) {
|
||||
Flight::response()->status(401)->write($result)->send();
|
||||
} else {
|
||||
echo $result;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Flight::response()
|
||||
->status(500)
|
||||
->write($e->getMessage())
|
||||
->send();
|
||||
}
|
||||
echo $this->uploadProvider->upload($key, $red, $blu, $name, $demoFile);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue