fix: return error details in import response for debugging
Problem: Errors during import were logged but not visible to user. Changes: - Backend: Collect error messages and return in response (first 10 errors) - Frontend: Display error details in import result box - UI: Red background when errors > 0, shows detailed error messages Now users can see exactly which rows failed and why. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
4b024e6d0f
commit
6b64cf31c4
2 files changed
+16
-6
No files matched your search
@@ -307,6 +307,7 @@ async def import_apple_health_baseline(
|
||||
updated = 0
|
||||
skipped = 0
|
||||
errors = 0
|
||||
error_details = [] # Collect error messages
|
||||
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
@@ -378,14 +379,15 @@ async def import_apple_health_baseline(
|
||||
|
||||
except Exception as e:
|
||||
import traceback
|
||||
error_detail = f"Row error: {str(e)}\nTraceback: {traceback.format_exc()}"
|
||||
logger.error(error_detail)
|
||||
print(error_detail) # Force output to Docker logs
|
||||
error_msg = f"Row {date if 'date' in locals() else 'unknown'}: {str(e)}"
|
||||
error_details.append(error_msg)
|
||||
logger.error(f"{error_msg}\n{traceback.format_exc()}")
|
||||
errors += 1
|
||||
|
||||
return {
|
||||
"inserted": inserted,
|
||||
"updated": updated,
|
||||
"skipped": skipped,
|
||||
"errors": errors
|
||||
"errors": errors,
|
||||
"error_details": error_details[:10] # Return first 10 errors
|
||||
}
|
||||
Reference in new issue
Block a user