refactor(errors): centralise legacy string error codes in ErrorCodes (M21)
~27 ad-hoc error codes (SLOT_TAKEN, USER_NOT_FOUND, VALIDATION, …) were raw strings, so ErrorCodes::message() returned the "unknown" fallback for them. Register all 14 distinct codes as constants with their messages and replace the raw usages across AdminApiController, MyAppointmentsController, CategoryController, PreRegistrationController and ClinicInvitationController. Wire values are kept identical (verified no consumer — admin SPA, nobat724_front, tauri — switches on these strings), so this is backward compatible. Regression: tests/Shared/ErrorCodesTest (wire values preserved + message resolves). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Category\Controller;
|
||||
|
||||
use App\Shared\Controller\BaseController;
|
||||
use App\Shared\Constant\ErrorCodes;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use OpenApi\Attributes as OA;
|
||||
@@ -33,7 +34,7 @@ class CategoryController extends BaseController
|
||||
|
||||
$newUrl = $map[$bundle] ?? null;
|
||||
if ($newUrl === null) {
|
||||
return $this->error('ERR_GONE', 'این endpoint حذف شده است', 410);
|
||||
return $this->error(ErrorCodes::ERR_GONE, 'این endpoint حذف شده است', 410);
|
||||
}
|
||||
|
||||
return $this->error(
|
||||
|
||||
Reference in New Issue
Block a user