API Error Handling
Summary
Native Recruitment maps application result kinds to four verified client-facing status families. Monolith controllers return MVC error results directly. Tenant absence has dedicated host middleware, while remote Employee Service and unexpected persistence failures lack lifecycle-specific mapping.
Audience
Developers, QA, support, and solution architects.
Reference Content
Error behavior is catalogued by verified HTTP status family and implementation boundary.
Verified status patterns
| Status family | Verified source and use |
|---|---|
| Success | Native DTOs, compatibility objects, HR Operations entities/lists, Employee envelopes |
| Created | Employee Service create only within the lifecycle handoff |
| Bad request | Native validation/default result; tenant absence; monolith input/state checks |
| Unauthorized | Authentication middleware for protected monolith controllers/actions |
| Forbidden | Monolith access, permission, role, ownership, or visibility denial |
| Not found | Missing offer, onboarding, candidate, exit, or public link |
| Conflict | Native terminal-state/idempotency conflicts and Employee create duplicate |
Native result mapping
Application NotFound maps to a not-found object containing a message. Conflict maps to a conflict message. Validation and unknown application error kinds map to bad request. Success normally maps to a direct DTO. The mapper does not define Unauthorized, Forbidden, or Created for Recruitment lifecycle commands.
Monolith error bodies
Controller errors are inconsistent by action: some return plain strings, some empty not-found/forbidden results, and framework authentication produces its standard challenge behavior. [ApiController] can reject binding/model-state failures before action execution.
Downstream failures
Recruitment's Employee client explicitly handles create conflict by searching for the existing employee. Other unsuccessful responses use standard HTTP exception behavior. No inspected lifecycle exception middleware converts these failures to a stable error contract, so an internal server error is possible.
Client behavior
The portal reads several possible error-message shapes and provides fallback text. A response indicating unauthorized clears or redirects the portal session. This does not establish a backend error contract.
Requires confirmation
- Standard error schema, correlation data, and safe detail policy.
- Mapping for downstream timeout, unavailability, malformed response, and partial success.
- Whether conflict or bad request is canonical for terminal lifecycle transitions.
- Compatibility parity for status codes and bodies.
Source References
microservices/src/recruitment-service/Api/EndpointResults.csmicroservices/src/recruitment-service/Program.csmicroservices/src/recruitment-service/Infrastructure/EmployeeServiceClient.csmicroservices/src/employee-service/Api/EmployeeDirectEndpoints.csControllers/RecruitmentController.csControllers/HrOperationsController.csUI/salary-ui/packages/api-client/src/axiosConfig.tsUI/salary-ui/apps/client-hrms-portal/src/pages/hr/RecruitmentOnboardingPage.tsxUI/salary-ui/apps/client-hrms-portal/src/pages/hr/HrOperationsPage.tsx
Related Articles
See Also
Keywords
- Error mapping
- Downstream failure
- Compatibility error parity
Revision Information
- Status: Draft
- Last reviewed: 2026-07-20
- Review cycle: Quarterly