Skip to content

Commit

Permalink
Polished the error dialog thrown when connecting for a sync fails
Browse files Browse the repository at this point in the history
  • Loading branch information
KoenZomers committed Dec 25, 2019
1 parent ea316a6 commit 882f9e7
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions KoenZomers.KeePass.OneDriveSync/Providers/OneDriveProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,20 @@ public static async Task<bool> SyncUsingOneDriveCloudProvider(Configuration data
errorMessage.Append("cloud storage provider");
break;
}
errorMessage.AppendLine(string.Format(" for database {0}", databaseConfig.KeePassDatabase.Name));
errorMessage.AppendLine(":");
errorMessage.AppendLine(string.Format(" for database {0}:", databaseConfig.KeePassDatabase.Name));
errorMessage.AppendLine();

// Revert to the most inner exception to get the best details on what went wrong
while (e.InnerException != null) e = e.InnerException;

errorMessage.AppendLine(e.Message);

// If there's an inner exception, show its message as well as it typically gives more detail why it went wrong
if (e.InnerException != null)
// Verify if we're offline
if (e.Message.Contains("remote name could not be resolved"))
{
errorMessage.AppendLine(e.InnerException.Message);

// Verify if we're offline
if (e.InnerException.Message.Contains("remote name could not be resolved"))
{
// Offline, don't display a modal dialog but use the status bar instead
KeePassDatabase.UpdateStatus("Can't connect. Working offline.");
return false;
}
// Offline, don't display a modal dialog but use the status bar instead
KeePassDatabase.UpdateStatus("Can't connect. Working offline.");
return false;
}

MessageBox.Show(errorMessage.ToString(), "Connection failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
Expand Down

0 comments on commit 882f9e7

Please sign in to comment.