Loading src/Exception/CategoryNotFoundException.php +1 −1 Original line number Diff line number Diff line Loading @@ -8,6 +8,6 @@ class CategoryNotFoundException extends AppException { public function __construct() { parent::__construct("Category not found", 404); parent::__construct("Category not found", ExceptionCode::CATEGORY_NOT_FOUND->value); } } src/Exception/ExceptionCode.php 0 → 100644 +13 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace App\Exception; enum ExceptionCode : int { case VALIDATION_ERROR = 1; case REQUEST_BODY_CONVERT_ERROR = 2; case PRODUCT_NOT_FOUND = 3; case CATEGORY_NOT_FOUND = 4; } src/Exception/HttpException/CategoryNotFoundException.php 0 → 100644 +17 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace App\Exception\HttpException; use App\Exception\CategoryNotFoundException as NotFoundException; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; class CategoryNotFoundException extends NotFoundException implements HttpExceptionInterface { public function getResponse(): JsonResponse { return new JsonResponse($this->getMessage(), Response::HTTP_NOT_FOUND); } } src/Exception/HttpException/HttpBadRequestException.php 0 → 100644 +17 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace App\Exception\HttpException; use App\Exception\AppException; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; class HttpBadRequestException extends AppException implements HttpExceptionInterface { public function getResponse(): JsonResponse { return new JsonResponse($this->getMessage(), Response::HTTP_BAD_REQUEST); } } src/Exception/HttpException/HttpExceptionInterface.php 0 → 100644 +12 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace App\Exception\HttpException; use Symfony\Component\HttpFoundation\JsonResponse; interface HttpExceptionInterface { public function getResponse(): JsonResponse; } Loading
src/Exception/CategoryNotFoundException.php +1 −1 Original line number Diff line number Diff line Loading @@ -8,6 +8,6 @@ class CategoryNotFoundException extends AppException { public function __construct() { parent::__construct("Category not found", 404); parent::__construct("Category not found", ExceptionCode::CATEGORY_NOT_FOUND->value); } }
src/Exception/ExceptionCode.php 0 → 100644 +13 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace App\Exception; enum ExceptionCode : int { case VALIDATION_ERROR = 1; case REQUEST_BODY_CONVERT_ERROR = 2; case PRODUCT_NOT_FOUND = 3; case CATEGORY_NOT_FOUND = 4; }
src/Exception/HttpException/CategoryNotFoundException.php 0 → 100644 +17 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace App\Exception\HttpException; use App\Exception\CategoryNotFoundException as NotFoundException; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; class CategoryNotFoundException extends NotFoundException implements HttpExceptionInterface { public function getResponse(): JsonResponse { return new JsonResponse($this->getMessage(), Response::HTTP_NOT_FOUND); } }
src/Exception/HttpException/HttpBadRequestException.php 0 → 100644 +17 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace App\Exception\HttpException; use App\Exception\AppException; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; class HttpBadRequestException extends AppException implements HttpExceptionInterface { public function getResponse(): JsonResponse { return new JsonResponse($this->getMessage(), Response::HTTP_BAD_REQUEST); } }
src/Exception/HttpException/HttpExceptionInterface.php 0 → 100644 +12 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace App\Exception\HttpException; use Symfony\Component\HttpFoundation\JsonResponse; interface HttpExceptionInterface { public function getResponse(): JsonResponse; }