π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[auth] Show contact support button on error dialogs
Neeraj Gupta29539d9db2cb
diff --git a/auth/lib/l10n/arb/app_en.arb b/auth/lib/l10n/arb/app_en.arbindex 58ad079a0b..0c2f9a0de4 100644--- a/auth/lib/l10n/arb/app_en.arb+++ b/auth/lib/l10n/arb/app_en.arb@@ -263,6 +263,8 @@"exportLogs": "Export logs","enterYourRecoveryKey": "Enter your recovery key","tempErrorContactSupportIfPersists": "It looks like something went wrong. Please retry after some time. If the error persists, please contact our support team.",+ "networkHostLookUpErr": "Unable to connect to Ente, please check your network settings and contact support if the error persists.",+ "networkConnectionRefusedErr": "Unable to connect to Ente, please retry after sometime. If the error persists, please contact support.","itLooksLikeSomethingWentWrongPleaseRetryAfterSome": "It looks like something went wrong. Please retry after some time. If the error persists, please contact our support team.","about": "About","weAreOpenSource": "We are open source!",diff --git a/auth/lib/services/passkey_service.dart b/auth/lib/services/passkey_service.dartindex 2be2bb1a02..4d7e9badd5 100644--- a/auth/lib/services/passkey_service.dart+++ b/auth/lib/services/passkey_service.dart@@ -49,7 +49,7 @@ class PasskeyService {);} catch (e) {Logger('PasskeyService').severe("failed to open passkey page", e);- showGenericErrorDialog(context: context).ignore();+ showGenericErrorDialog(context: context, error: e).ignore();}}}diff --git a/auth/lib/services/user_service.dart b/auth/lib/services/user_service.dartindex 182dee2d25..ca88796f15 100644--- a/auth/lib/services/user_service.dart+++ b/auth/lib/services/user_service.dart@@ -101,7 +101,7 @@ class UserService {);return;}- unawaited(showGenericErrorDialog(context: context));+ unawaited(showGenericErrorDialog(context: context, error: null));} on DioException catch (e) {await dialog.hide();_logger.info(e);@@ -114,12 +114,12 @@ class UserService {),);} else {- unawaited(showGenericErrorDialog(context: context));+ unawaited(showGenericErrorDialog(context: context, error: e));}} catch (e) {await dialog.hide();_logger.severe(e);- unawaited(showGenericErrorDialog(context: context));+ unawaited(showGenericErrorDialog(context: context, error: e));}}@@ -227,7 +227,7 @@ class UserService {//to close and only then to show the error dialog.Future.delayed(const Duration(milliseconds: 150),- () => showGenericErrorDialog(context: context),+ () => showGenericErrorDialog(context: context, error: e),);rethrow;}@@ -248,7 +248,10 @@ class UserService {}} catch (e) {_logger.severe(e);- await showGenericErrorDialog(context: context);+ await showGenericErrorDialog(+ context: context,+ error: e,+ );return null;}}diff --git a/auth/lib/ui/account/password_entry_page.dart b/auth/lib/ui/account/password_entry_page.dartindex 9b1ce61812..b7e3e14694 100644--- a/auth/lib/ui/account/password_entry_page.dart+++ b/auth/lib/ui/account/password_entry_page.dart@@ -412,7 +412,10 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {_logger.severe(e, s);await dialog.hide();// ignore: unawaited_futures- showGenericErrorDialog(context: context);+ showGenericErrorDialog(+ context: context,+ error: e,+ );}}@@ -472,7 +475,10 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {_logger.severe(e, s);await dialog.hide();// ignore: unawaited_futures- showGenericErrorDialog(context: context);+ showGenericErrorDialog(+ context: context,+ error: e,+ );}}@@ -500,7 +506,10 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {);} else {// ignore: unawaited_futures- showGenericErrorDialog(context: context);+ showGenericErrorDialog(+ context: context,+ error: e,+ );}}}diff --git a/auth/lib/ui/account/verify_recovery_page.dart b/auth/lib/ui/account/verify_recovery_page.dartindex 03ed81fdf0..bb4ebb068a 100644--- a/auth/lib/ui/account/verify_recovery_page.dart+++ b/auth/lib/ui/account/verify_recovery_page.dart@@ -47,7 +47,10 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {"Please check your internet connection and try again.",);} else {- await showGenericErrorDialog(context: context);+ await showGenericErrorDialog(+ context: context,+ error: e,+ );}return;}@@ -107,7 +110,10 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {);} catch (e) {// ignore: unawaited_futures- showGenericErrorDialog(context: context);+ showGenericErrorDialog(+ context: context,+ error: e,+ );return;}}diff --git a/auth/lib/ui/components/buttons/button_widget.dart b/auth/lib/ui/components/buttons/button_widget.dartindex 1932cc02bd..9e589cd7a0 100644--- a/auth/lib/ui/components/buttons/button_widget.dart+++ b/auth/lib/ui/components/buttons/button_widget.dart@@ -485,7 +485,10 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {} else if (exception != null) {//This is to show the execution was unsuccessful if the dialog is manually//closed before the execution completes.- showGenericErrorDialog(context: context);+ showGenericErrorDialog(+ context: context,+ error: exception,+ );}}diff --git a/auth/lib/ui/home_page.dart b/auth/lib/ui/home_page.dartindex a2f97f07a6..ee78399944 100644--- a/auth/lib/ui/home_page.dart+++ b/auth/lib/ui/home_page.dart@@ -56,7 +56,8 @@ class _HomePageState extends State<HomePage> {final scaffoldKey = GlobalKey<ScaffoldState>();final TextEditingController _textController = TextEditingController();- final bool _autoFocusSearch = PreferenceService.instance.shouldAutoFocusOnSearchBar();+ final bool _autoFocusSearch =+ PreferenceService.instance.shouldAutoFocusOnSearchBar();bool _showSearchBox = false;String _searchText = "";List<Code>? _allCodes;@@ -448,7 +449,10 @@ class _HomePageState extends State<HomePage> {CodeStore.instance.addCode(newCode);_focusNewCode(newCode);} catch (e, s) {- showGenericErrorDialog(context: context);+ showGenericErrorDialog(+ context: context,+ error: e,+ );_logger.severe("error while handling deeplink", e, s);}}diff --git a/auth/lib/ui/passkey_page.dart b/auth/lib/ui/passkey_page.dartindex eab0b72f99..4181c474e9 100644--- a/auth/lib/ui/passkey_page.dart+++ b/auth/lib/ui/passkey_page.dart@@ -69,7 +69,7 @@ class _PasskeyPageState extends State<PasskeyPage> {return;} catch (e, s) {_logger.severe("failed to check status", e, s);- showGenericErrorDialog(context: context).ignore();+ showGenericErrorDialog(context: context, error: e).ignore();return;}await UserService.instance.onPassKeyVerified(context, response);@@ -111,7 +111,7 @@ class _PasskeyPageState extends State<PasskeyPage> {}} catch (e, s) {_logger.severe('passKey: failed to handle deeplink', e, s);- showGenericErrorDialog(context: context).ignore();+ showGenericErrorDialog(context: context, error: e).ignore();}}@@ -169,7 +169,7 @@ class _PasskeyPageState extends State<PasskeyPage> {await checkStatus();} catch (e) {debugPrint('failed to check status %e');- showGenericErrorDialog(context: context).ignore();+ showGenericErrorDialog(context: context, error: e).ignore();}},shouldSurfaceExecutionStates: true,diff --git a/auth/lib/ui/settings/account_section_widget.dart b/auth/lib/ui/settings/account_section_widget.dartindex d51b2dd873..47e639c2e7 100644--- a/auth/lib/ui/settings/account_section_widget.dart+++ b/auth/lib/ui/settings/account_section_widget.dart@@ -111,7 +111,10 @@ class AccountSectionWidget extends StatelessWidget {CryptoUtil.bin2hex(Configuration.instance.getRecoveryKey());} catch (e) {// ignore: unawaited_futures- showGenericErrorDialog(context: context);+ showGenericErrorDialog(+ context: context,+ error: e,+ );return;}// ignore: unawaited_futuresdiff --git a/auth/lib/ui/settings/security_section_widget.dart b/auth/lib/ui/settings/security_section_widget.dartindex 49672b0368..678a4ddfa1 100644--- a/auth/lib/ui/settings/security_section_widget.dart+++ b/auth/lib/ui/settings/security_section_widget.dart@@ -182,7 +182,10 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {PasskeyService.instance.openPasskeyPage(buildContext).ignore();} catch (e, s) {_logger.severe("failed to open passkey page", e, s);- await showGenericErrorDialog(context: context);+ await showGenericErrorDialog(+ context: context,+ error: e,+ );}}diff --git a/auth/lib/utils/dialog_util.dart b/auth/lib/utils/dialog_util.dartindex 26697f0f7e..24636bf889 100644--- a/auth/lib/utils/dialog_util.dart+++ b/auth/lib/utils/dialog_util.dart@@ -14,6 +14,7 @@ import 'package:ente_auth/ui/components/dialog_widget.dart';import 'package:ente_auth/ui/components/models/button_result.dart';import 'package:ente_auth/ui/components/models/button_type.dart';import 'package:ente_auth/utils/email_util.dart';+import 'package:flutter/foundation.dart';import 'package:flutter/material.dart';typedef DialogBuilder = DialogWidget Function(BuildContext context);@@ -70,16 +71,77 @@ Future<ButtonResult?> showErrorDialogForException({);}+String parseErrorForUI(+ BuildContext context,+ String genericError, {+ Object? error,+ bool surfaceError = kDebugMode,+}) {+ try {+ if (error == null) {+ return genericError;+ }+ if (error is DioException) {+ final DioException dioError = error;+ if (dioError.type == DioExceptionType.unknown) {+ if (dioError.error.toString().contains('Failed host lookup')) {+ return context.l10n.networkHostLookUpErr;+ } else if (dioError.error.toString().contains('SocketException')) {+ return context.l10n.networkConnectionRefusedErr;+ }+ }+ }+ // return generic error if the user is not internal and the error is not in debug mode+ if (!kDebugMode) {+ return genericError;+ }+ String errorInfo = "";+ if (error is DioException) {+ final DioException dioError = error;+ if (dioError.type == DioExceptionType.badResponse) {+ if (dioError.response?.data["code"] != null) {+ errorInfo = "Reason: " + dioError.response!.data["code"];+ } else {+ errorInfo = "Reason: " + dioError.response!.data.toString();+ }+ } else if (dioError.type == DioExceptionType.unknown) {+ errorInfo = "Reason: " + dioError.error.toString();+ } else {+ errorInfo = "Reason: " + dioError.type.toString();+ }+ } else {+ if (kDebugMode) {+ errorInfo = error.toString();+ } else {+ errorInfo = error.toString().split('Source stack')[0];+ }+ }+ if (errorInfo.isNotEmpty) {+ return "$genericError\n\n$errorInfo";+ }+ return genericError;+ } catch (e) {+ return genericError;+ }+}+///Will return null if dismissed by tapping outsideFuture<ButtonResult?> showGenericErrorDialog({required BuildContext context,bool isDismissible = true,+ required Object? error,}) async {+ final errorBody = parseErrorForUI(+ context,+ context.l10n.itLooksLikeSomethingWentWrongPleaseRetryAfterSome,+ error: error,+ );+return showDialogWidget(context: context,title: context.l10n.error,icon: Icons.error_outline_outlined,- body: context.l10n.itLooksLikeSomethingWentWrongPleaseRetryAfterSome,+ body: errorBody,isDismissible: isDismissible,buttons: [ButtonWidget(