From 655eb123b99e8b62ec27728f0a4e4e158036bba0 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Tue, 10 May 2011 11:27:20 +1200 Subject: [PATCH] Give more polished error messages --- OpenRA.FileFormats/InstallUtils.cs | 2 +- OpenRA.Mods.Cnc/Widgets/CncInstallLogic.cs | 24 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/OpenRA.FileFormats/InstallUtils.cs b/OpenRA.FileFormats/InstallUtils.cs index 36ab2de35e..f699778ed8 100644 --- a/OpenRA.FileFormats/InstallUtils.cs +++ b/OpenRA.FileFormats/InstallUtils.cs @@ -91,7 +91,7 @@ namespace OpenRA.FileFormats foreach(var f in extracted) File.Delete(f); - onError("Archive corrupt"); + onError("Invalid archive"); return false; } return true; diff --git a/OpenRA.Mods.Cnc/Widgets/CncInstallLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncInstallLogic.cs index d5c1b57628..0da650442a 100755 --- a/OpenRA.Mods.Cnc/Widgets/CncInstallLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncInstallLogic.cs @@ -166,8 +166,7 @@ namespace OpenRA.Mods.Cnc.Widgets void ShowDownloadDialog() { statusLabel.GetText = () => "Initializing..."; - progressBar.SetIndeterminate(false); - + progressBar.SetIndeterminate(true); var retryButton = panel.GetWidget("RETRY_BUTTON"); retryButton.IsVisible = () => false; @@ -179,6 +178,9 @@ namespace OpenRA.Mods.Cnc.Widgets Action onDownloadProgress = i => { + if (progressBar.Indeterminate) + progressBar.SetIndeterminate(false); + progressBar.Percentage = i.ProgressPercentage; statusLabel.GetText = () => "Downloading {1}/{2} kB ({0}%)".F(i.ProgressPercentage, i.BytesReceived / 1024, i.TotalBytesToReceive / 1024); }; @@ -193,12 +195,26 @@ namespace OpenRA.Mods.Cnc.Widgets statusLabel.GetText = () => "Error: "+s; retryButton.IsVisible = () => true; }; - + Action onDownloadComplete = (i, cancelled) => { if (i.Error != null) { - onError(i.Error.Message); + var message = i.Error.Message; + var except = i.Error as System.Net.WebException; + if (except != null) + { + Console.WriteLine("{0}",except.Status); + + if (except.Status == WebExceptionStatus.ProtocolError) + message = "File not found on remote server"; + else if (except.Status == WebExceptionStatus.NameResolutionFailure || + except.Status == WebExceptionStatus.Timeout || + except.Status == WebExceptionStatus.ConnectFailure) + message = "Cannot connect to remote server"; + } + + onError(message); return; } else if (cancelled)