Updated Somnia API exceptions to use the new API error handling.

This commit is contained in:
2024-10-18 17:58:27 +02:00
parent facd5bc9c0
commit fbee23c022
3 changed files with 58 additions and 23 deletions
+5 -1
View File
@@ -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);