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:
hamed
2026-06-28 21:12:23 +03:30
co-authored by Claude Opus 4.8
parent 96a86dbfed
commit 4b80616a17
8 changed files with 102 additions and 29 deletions
@@ -63,7 +63,7 @@ class PreRegistrationController extends BaseController
}
if ($this->preRegRepo->hasPendingForMobile($mobile)) {
return $this->error('DUPLICATE_REQUEST', 'درخواست ثبت‌نام شما در حال بررسی است', 409);
return $this->error(ErrorCodes::DUPLICATE_REQUEST, 'درخواست ثبت‌نام شما در حال بررسی است', 409);
}
$preReg = new PreRegistration($type, $name, $mobile, $info);