Skip to content

improved the error messages in counseling page

#152 (closed)

I've improved the error handling in the Counseling page to display the exact backend error message instead of a generic one.

What was changed:

Imported isApiError helper function from @/lib/api Updated the error handling in the onError callback to extract the backend error message from error.response.data.detail What improved:

Before: Displayed generic message like "Failed to update counseling: Request failed with status code 400" After: Displays the exact backend message like "Failed to update counseling: Failed to update counselling status: No camp visit found for patient with book_no 1 at the current camp" The fix tries multiple approaches to extract the error:

Uses the isApiError type guard to check for detail property directly Checks axios error format error.response?.data?.detail Falls back to error.message or "Unknown error"

Edited by Bikkumalla Sai Krishna

Merge request reports

Loading