From 5aed0a9bcc892917034b2cbc51eab613c4d8d576 Mon Sep 17 00:00:00 2001 From: Johannes Meyer zum Alten Borgloh Date: Thu, 6 Dec 2018 20:48:10 +0100 Subject: [PATCH] #295 Handle failure in agreeing to Tumblr privacy consent --- .../Properties/Resources.Designer.cs | 11 +++++++- .../Properties/Resources.resx | 5 +++- .../Services/ConfirmTumblrPrivacyConsent.cs | 25 +++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/TumblThree/TumblThree.Applications/Properties/Resources.Designer.cs b/src/TumblThree/TumblThree.Applications/Properties/Resources.Designer.cs index df10ae4..9e373f6 100644 --- a/src/TumblThree/TumblThree.Applications/Properties/Resources.Designer.cs +++ b/src/TumblThree/TumblThree.Applications/Properties/Resources.Designer.cs @@ -150,6 +150,15 @@ public static string Body { } } + /// + /// Looks up a localized string similar to Confirming the Tumblr privacy consent failed. There might a connection issue.. + /// + public static string ConfirmingTumblrPrivacyConsentFailed { + get { + return ResourceManager.GetString("ConfirmingTumblrPrivacyConsentFailed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Conversation: {0}. /// @@ -729,7 +738,7 @@ public static string Textfile { } /// - /// Looks up a localized string similar to A connection timout occured during {0} of {1}.. + /// Looks up a localized string similar to A connection timeout occured during {0} of {1}.. /// public static string TimeoutReached { get { diff --git a/src/TumblThree/TumblThree.Applications/Properties/Resources.resx b/src/TumblThree/TumblThree.Applications/Properties/Resources.resx index 4c3b63f..56e1397 100644 --- a/src/TumblThree/TumblThree.Applications/Properties/Resources.resx +++ b/src/TumblThree/TumblThree.Applications/Properties/Resources.resx @@ -147,6 +147,9 @@ Body: {0] + + Confirming the Tumblr privacy consent failed. There might a connection issue. + Conversation: {0} @@ -342,7 +345,7 @@ Text file - A connection timout occured during {0} of {1}. + A connection timeout occured during {0} of {1}. Title: {0} diff --git a/src/TumblThree/TumblThree.Applications/Services/ConfirmTumblrPrivacyConsent.cs b/src/TumblThree/TumblThree.Applications/Services/ConfirmTumblrPrivacyConsent.cs index 22f6717..44d573f 100644 --- a/src/TumblThree/TumblThree.Applications/Services/ConfirmTumblrPrivacyConsent.cs +++ b/src/TumblThree/TumblThree.Applications/Services/ConfirmTumblrPrivacyConsent.cs @@ -1,10 +1,14 @@ using System; using System.Collections.Generic; using System.ComponentModel.Composition; +using System.Globalization; using System.Net; using System.Text.RegularExpressions; using System.Threading.Tasks; +using TumblThree.Applications.Properties; +using TumblThree.Domain; + namespace TumblThree.Applications.Services { [Export(typeof(IConfirmTumblrPrivacyConsent)), Export] @@ -25,6 +29,27 @@ public ConfirmTumblrPrivacyConsent(IShellService shellService, ISharedCookieServ } public async Task ConfirmPrivacyConsentAsync() + { + try + { + await PerformPrivacyConsentRequestAsync(); + } + catch (TimeoutException timeoutException) + { + const string message = "confirming the Tumblr privacy consent"; + Logger.Error("{0}, {1}", string.Format(CultureInfo.CurrentCulture, Resources.TimeoutReached, message), + timeoutException); + shellService.ShowError(timeoutException, Resources.TimeoutReached, message); + } + catch (Exception exception) + { + Logger.Error("{0}, {1}", string.Format(CultureInfo.CurrentCulture, Resources.ConfirmingTumblrPrivacyConsentFailed), + exception); + shellService.ShowError(exception, Resources.ConfirmingTumblrPrivacyConsentFailed); + } + } + + private async Task PerformPrivacyConsentRequestAsync() { if (CheckIfLoggedInAsync()) return;