Updated Somnia API exceptions to use the new API error handling.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\ApiErrorException;
|
||||
use App\DTO\ApiErrorMessage;
|
||||
use App\Entity\ConfigVariable;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -91,7 +93,9 @@ class ConfigVariableController extends AbstractController
|
||||
public function getVariablesBySection(ConfigVariableRepository $repo, string $section): Response
|
||||
{
|
||||
if(\is_null($section) || $section == '') {
|
||||
return new Response("Invalid section value", 404);
|
||||
throw new ApiErrorException(
|
||||
new ApiErrorMessage(400, ApiErrorMessage::TYPE_INVALID_REQUEST_BODY_FORMAT)
|
||||
);
|
||||
}
|
||||
|
||||
$varList = $repo->findAllBySection($section);
|
||||
|
||||
Reference in New Issue
Block a user