Fix error propagation: surface API validation messages in the UI #29
Reference in New Issue
Block a user
Delete Branch "fix/error-propagation-28"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Surface upstream API validation messages in the browser instead of swallowing them in generic fallbacks.
Why
When cv-matcher-api rejects a job URL or file with an actionable 4xx message (e.g. "Only PDF files are supported", "Could not extract enough job text"), the browser was showing a hardcoded fallback string. Users had no idea what went wrong or how to fix it. This wires up the full error path from server business rules to the UI.
Changes
startup-helpers/StartupExtensions.cs—UseJsonExceptionHandlernow mapsInvalidOperationException→ 400 Bad Request (was incorrectly promoted to 500); all other unhandled exceptions remain 500api/Controllers/CvMatcherController.cs— catchesRefit.ApiExceptionwith status < 500 and forwards the upstreamErrorResponsebody (with its human-readableErrormessage) instead of returning a generic 502common/Responses/ErrorResponse.cs— removed strayScoreproperty; captcha score moved toDetailweb/wwwroot/js/main.js— addedextractApiError(body, status, fallbackKey, rateLimitKey)helper; updated all four failure handlers (CV upload fetch, CV match fetch, contact form.fail(), subscribe form.fail()) to read the server error body and display it for 4xx, falling back to the i18n string only for 5xx or unparseable responsesTesting
dotnet build myAi.sln→ 0 errors, 0 warningsRisk Assessment
Checklist