Error handling & observability ở production
Không nên có mộtcatch(error) => toast('Có lỗi') cho mọi trường hợp. Với Inertia, phần lớn error semantics vẫn đến từ backend framework.
4 nhóm cần tách
Laravel exception rendering
Tùy version Laravel, hãy cấu hình exception response theo cơ chế framework đang dùng. Ý tưởng là với status production như 403/404/500/503, trả một Inertia error page thay vì HTML debug response.React error page
Log tối thiểu nên có
- request/correlation ID;
- authenticated user ID nếu có;
- route + method;
- exception class/message;
- DB/service context không chứa secret;
- timing của dependency quan trọng;
- deployment/version identifier.