Skip to content

fix: improve error handling — stop silently swallowing errors#1

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783059186-improve-error-handling
Open

fix: improve error handling — stop silently swallowing errors#1
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783059186-improve-error-handling

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Audited all catch blocks across the codebase and fixed cases where errors were silently swallowed or lost.

Errors now rethrown to callers:

  • VocPassAuthService.handleTokenLogin — previously caught the error, cleared the token, and returned silently. Now rethrows so callers (deep link handler) know login failed. The _handleTokenLoginAndSyncNotify in app.dart catches and logs the rethrown error.
  • VocPassAuthService.restoreSession — changed Future<void>Future<bool> to indicate success/failure. Existing callers that await it are unaffected.

Silent data corruption fixed:

  • _W2MEditSheet date parsing: catch (_) { return DateTime.now(); } silently substituted today's date for unparseable strings. Now returns null and filters with .whereType<DateTime>() — unparseable dates are dropped instead of corrupted.

Silent failures now surfaced to UI:

  • RestaurantDetailScreen._loadMenu: added _menuError state field; the menu section now shows "菜單載入失敗" on failure instead of silently hiding the error and showing the empty-state message.

Debug logging added to 14 catch blocks that previously used catch (_) {} or catch (e) without logging — all now include if (kDebugMode) print(...) with context:

  • following_screen._fetchProfile, forum_verification_sheet.refreshMe(), forum_service.fetchAdminInfo, forum_screen.fetchTags, api_service.fetchAttendanceWithCurriculum (curriculum sub-fetch), and all screen-level generic-catch blocks in home_screen, score_screen, exam_score_screen, attendance_screen, curriculum_screen.

Link to Devin session: https://app.devin.ai/sessions/bd31ccf3d1444f0ab162684bed8684eb
Requested by: @HansHans135

- Add debug logging to all catch blocks that previously used catch(_){}
  or catch(_) with no logging, across 14 files
- vocpass_auth_service: handleTokenLogin now rethrows on failure so
  callers can react; restoreSession returns bool success status
- app.dart: wrap deep-link token login in try/catch since it now throws
- w2m_result_screen: filter out unparseable dates instead of silently
  substituting DateTime.now()
- restaurant_screen: surface menu load errors in the UI (_menuError)
- following_screen: log profile fetch failures instead of empty catch
- forum_verification_sheet: log refreshMe() failures
- forum_service/forum_screen: log fetchAdminInfo and fetchTags failures
- api_service: log curriculum fetch failure in fetchAttendanceWithCurriculum
- All screen-level catch blocks (score, exam_score, curriculum,
  attendance, home) now log the original error for debugging while
  still showing user-friendly messages

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@HansHans135 HansHans135 self-assigned this Jul 3, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant