Give more polished error messages

This commit is contained in:
Paul Chote
2011-05-10 11:27:20 +12:00
parent 3d493d3ace
commit 655eb123b9
2 changed files with 21 additions and 5 deletions

View File

@@ -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;

View File

@@ -166,8 +166,7 @@ namespace OpenRA.Mods.Cnc.Widgets
void ShowDownloadDialog()
{
statusLabel.GetText = () => "Initializing...";
progressBar.SetIndeterminate(false);
progressBar.SetIndeterminate(true);
var retryButton = panel.GetWidget<CncMenuButtonWidget>("RETRY_BUTTON");
retryButton.IsVisible = () => false;
@@ -179,6 +178,9 @@ namespace OpenRA.Mods.Cnc.Widgets
Action<DownloadProgressChangedEventArgs> 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<AsyncCompletedEventArgs, bool> 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)