π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
ErrDialog: Surface network error & contact support
Neeraj Gupta7230d52dd25b
diff --git a/lib/core/constants.dart b/lib/core/constants.dartindex e0fe083cde..9ae2e8b660 100644--- a/lib/core/constants.dart+++ b/lib/core/constants.dart@@ -64,3 +64,5 @@ const defaultRadiusValue = 40.0;const galleryGridSpacing = 2.0;const searchSectionLimit = 7;++bool isInternalUser = false;diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dartindex efac6e1062..1326d41a55 100644--- a/lib/generated/intl/messages_en.dart+++ b/lib/generated/intl/messages_en.dart@@ -869,6 +869,10 @@ class MessageLookup extends MessageLookupByLibrary {"movingFilesToAlbum":MessageLookupByLibrary.simpleMessage("Moving files to album..."),"name": MessageLookupByLibrary.simpleMessage("Name"),+ "networkConnectionRefusedErr": MessageLookupByLibrary.simpleMessage(+ "Unable to connect to Ente, please retry after sometime. If the error persists, please contact support."),+ "networkHostLookUpErr": MessageLookupByLibrary.simpleMessage(+ "Unable to connect to Ente, please check your network settings and contact support if the error persists."),"never": MessageLookupByLibrary.simpleMessage("Never"),"newAlbum": MessageLookupByLibrary.simpleMessage("New album"),"newToEnte": MessageLookupByLibrary.simpleMessage("New to ente"),diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dartindex e0af479e32..9b05919d31 100644--- a/lib/generated/l10n.dart+++ b/lib/generated/l10n.dart@@ -6529,6 +6529,26 @@ class S {);}+ /// `Unable to connect to Ente, please check your network settings and contact support if the error persists.`+ String get networkHostLookUpErr {+ return Intl.message(+ 'Unable to connect to Ente, please check your network settings and contact support if the error persists.',+ name: 'networkHostLookUpErr',+ desc: '',+ args: [],+ );+ }++ /// `Unable to connect to Ente, please retry after sometime. If the error persists, please contact support.`+ String get networkConnectionRefusedErr {+ return Intl.message(+ 'Unable to connect to Ente, please retry after sometime. If the error persists, please contact support.',+ name: 'networkConnectionRefusedErr',+ desc: '',+ args: [],+ );+ }+/// `Cached data`String get cachedData {return Intl.message(diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arbindex 18943691e5..d38aef2859 100644--- a/lib/l10n/intl_en.arb+++ b/lib/l10n/intl_en.arb@@ -929,6 +929,8 @@"itLooksLikeSomethingWentWrongPleaseRetryAfterSome": "It looks like something went wrong. Please retry after some time. If the error persists, please contact our support team.","error": "Error","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.","cachedData": "Cached data","clearCaches": "Clear caches","remoteImages": "Remote images",diff --git a/lib/services/feature_flag_service.dart b/lib/services/feature_flag_service.dartindex 6899d99ede..0a630eb420 100644--- a/lib/services/feature_flag_service.dart+++ b/lib/services/feature_flag_service.dart@@ -71,9 +71,10 @@ class FeatureFlagService {bool isInternalUserOrDebugBuild() {final String? email = Configuration.instance.getEmail();final userID = Configuration.instance.getUserID();- return (email != null && email.endsWith("@ente.io")) ||+ isInternalUser = (email != null && email.endsWith("@ente.io")) ||_internalUserIDs.contains(userID) ||kDebugMode;+ return isInternalUser;}Future<void> fetchFeatureFlags() async {diff --git a/lib/services/user_service.dart b/lib/services/user_service.dartindex 6fb418aae9..c5b14a305c 100644--- a/lib/services/user_service.dart+++ b/lib/services/user_service.dart@@ -127,12 +127,14 @@ class UserService {),);} else {- unawaited(showGenericErrorDialog(context: context));+ unawaited(showGenericErrorDialog(context: context, error: e));}- } catch (e) {+ } catch (e, s) {await dialog.hide();- _logger.severe(e);- unawaited(showGenericErrorDialog(context: context));+ _logger.severe(e, s);+ unawaited(+ showGenericErrorDialog(context: context, error: e),+ );}}diff --git a/lib/utils/dialog_util.dart b/lib/utils/dialog_util.dartindex acf49c0bff..0668487894 100644--- a/lib/utils/dialog_util.dart+++ b/lib/utils/dialog_util.dart@@ -2,6 +2,7 @@ import "package:dio/dio.dart";import "package:flutter/foundation.dart";import 'package:flutter/material.dart';import "package:flutter/services.dart";+import "package:photos/core/constants.dart";import "package:photos/generated/l10n.dart";import 'package:photos/models/button_result.dart';import 'package:photos/models/typedefs.dart';@@ -12,6 +13,7 @@ import 'package:photos/ui/components/action_sheet_widget.dart';import 'package:photos/ui/components/buttons/button_widget.dart';import 'package:photos/ui/components/dialog_widget.dart';import 'package:photos/ui/components/models/button_type.dart';+import "package:photos/utils/email_util.dart";typedef DialogBuilder = DialogWidget Function(BuildContext context);@@ -69,32 +71,95 @@ Future<ButtonResult?> showErrorDialogForException({);}+String parseErrorForUI(+ BuildContext context,+ String genericError, {+ Object? error,+ bool surfaceError = kDebugMode,+}) {+ if (error == null) {+ return genericError;+ }+ if (error is DioError) {+ final DioError dioError = error;+ if (dioError.type == DioErrorType.other) {+ if (dioError.error.toString().contains('Failed host lookup')) {+ return S.of(context).networkHostLookUpErr;+ } else if (dioError.error.toString().contains('SocketException')) {+ return S.of(context).networkConnectionRefusedErr;+ }+ }+ }+ // return generic error if the user is not internal and the error is not in debug mode+ if (!(isInternalUser && kDebugMode)) {+ return genericError;+ }+ String errorInfo = "";+ if (error is DioError) {+ final DioError dioError = error;+ if (dioError.type == DioErrorType.response) {+ if (dioError.response?.data["code"] != null) {+ errorInfo = "Reason: " + dioError.response!.data["code"];+ } else {+ errorInfo = "Reason: " + dioError.response!.data.toString();+ }+ } else if (dioError.type == DioErrorType.other) {+ 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;+}+///Will return null if dismissed by tapping outsideFuture<ButtonResult?> showGenericErrorDialog({required BuildContext context,bool isDismissible = true,- Exception? error,- bool surfaceError = kDebugMode,+ Object? error,}) async {- String errorBody =- S.of(context).itLooksLikeSomethingWentWrongPleaseRetryAfterSome;- if (surfaceError && error != null) {- errorBody = '$errorBody\n\n${error.toString()}';- }- return showDialogWidget(+ final errorBody = parseErrorForUI(+ context,+ S.of(context).itLooksLikeSomethingWentWrongPleaseRetryAfterSome,+ error: error,+ );++ final ButtonResult? result = await showDialogWidget(context: context,title: S.of(context).error,icon: Icons.error_outline_outlined,body: errorBody,isDismissible: isDismissible,- buttons: const [+ buttons: [ButtonWidget(- buttonType: ButtonType.secondary,- labelText: "OK",+ buttonType: ButtonType.primary,+ labelText: S.of(context).ok,+ buttonAction: ButtonAction.first,isInAlert: true,),+ ButtonWidget(+ buttonType: ButtonType.secondary,+ labelText: S.of(context).contactSupport,+ buttonAction: ButtonAction.second,+ onTap: () async {+ await sendLogs(+ context,+ S.of(context).contactSupport,+ "[email protected]",+ postShare: () {},+ );+ },+ ),],);+ return result;}DialogWidget choiceDialog({