Sanitize user facing error - #8721
Conversation
There was a problem hiding this comment.
Pull request overview
This PR sanitizes user-facing errors—particularly VPN-related ones—by introducing a regex-based VPN error classification that maps technical errors to localized, user-friendly messages, while standardizing logging to record raw (non-localized) error details for debugging.
Changes:
- Add VPN error classification in the shared error localization extension and use it for VPN start/stop and split-tunnel failures.
- Standardize error logging across multiple features to log
failure.error(raw) instead offailure.localizedErrorMessage. - Update English localization resources with new VPN/connection error strings and remove an obsolete auth/session-related test.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/core/models/app_setting_auth_session_test.dart | Removes an app setting auth/session unit test. |
| lib/lantern/lantern_ffi_service.dart | Logs VPN start/stop errors and maps raw FFI errors to localized descriptions. |
| lib/features/vpn/vpn_switch.dart | Logs raw VPN state-change errors instead of localized messages. |
| lib/features/vpn/server_selection.dart | Logs raw VPN connection errors on retry failures. |
| lib/features/vpn/provider/available_servers_notifier.dart | Logs raw errors when loading available servers fails. |
| lib/features/system_tray/provider/system_tray_notifier.dart | Logs raw errors for tray-driven connect failures. |
| lib/features/private_server/private_server_deploy.dart | Logs raw errors when canceling a deployment fails. |
| lib/features/private_server/manually_server_setup.dart | Logs raw errors when adding a server fails. |
| lib/features/plans/provider/plans_notifier.dart | Removes a plan-selection info log line. |
| lib/features/macos_extension/macos_extension_dialog.dart | Logs raw errors for macOS extension flow failures. |
| lib/features/language/language.dart | Logs raw errors when locale updates fail. |
| lib/features/home/provider/home_notifier.dart | Logs raw errors for user data fetch/refresh flows. |
| lib/features/home/provider/feature_flag_notifier.dart | Logs raw errors for feature flag fetch failures. |
| lib/features/auth/create_password.dart | Logs raw errors for create-password failures. |
| lib/features/auth/choose_payment_method.dart | Logs raw errors for payment redirect failures. |
| lib/features/account/delete_account.dart | Logs raw errors for account deletion failures. |
| lib/features/account/account.dart | Logs raw errors for logout failures. |
| lib/core/services/app_purchase.dart | Logs raw errors when purchase-related user data fetch fails. |
| lib/core/extensions/error.dart | Adds VPN error regex classification and makes default user-facing errors more generic/sanitized. |
| assets/locales/en.po | Adds new English strings for VPN/connection error categories. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| msgid "err_check_connection" | ||
| msgstr "Unable to connect. Check your internet connection." | ||
|
|
||
| msgid "err_service_unavailable" | ||
| msgstr "Service temporarily unavailable. Trying again..." | ||
|
|
||
| msgid "err_connection_failed" | ||
| msgstr "Connection failed. Please try again." | ||
|
|
||
| msgid "err_ruleset_failed" | ||
| msgstr "Unable to load routing configuration. Retrying..." |
There was a problem hiding this comment.
The new VPN error message keys (err_check_connection, err_service_unavailable, err_connection_failed, err_ruleset_failed) are only added to en.po. If the app locale is set to something else, i18n lookups for these keys may fall back to showing the raw msgid (e.g., "err_check_connection") to users. Please add these msgids to the other locale .po files (even as English placeholders) or implement a fallback to English for missing keys.
|
LGTM |
This pull request introduces improvements to error handling and user feedback across the codebase, especially for VPN-related errors. It standardizes error logging, enhances user-facing error messages with more descriptive and categorized responses, and updates localization resources accordingly. Additionally, it removes an obsolete test file.
Error Handling and User Feedback Improvements
error.dartthat maps technical error messages to user-friendly, localized error strings using regex patterns. This ensures users see clearer and more actionable error messages for common VPN issues.en.pofor various VPN and connection errors, supporting the new error categorization.Standardization of Logging and Error Reporting
errorfield rather than the localized error message, making logs more useful for debugging. This affects many files, including account, authentication, payment, server, and VPN-related features. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19]VPN Service Error Handling
lantern_ffi_service.dartby ensuring that errors returned from VPN start/stop operations are both logged and mapped to localized error descriptions, providing a better user experience and more actionable logs. [1] [2] [3]Codebase Cleanup
app_setting_auth_session_test.dart, cleaning up unused or redundant tests.