Skip to content

Commit a145853

Browse files
committed
fix exception if update download page is 404
1 parent 1f58caf commit a145853

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

UnityLauncherPro/Tools.cs

+14-3
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,22 @@ static string ParseDownloadURLFromWebpage(string version)
368368
if (Tools.VersionIsBeta(version)) website = "https://unity3d.com/unity/beta/" + version;
369369
if (Tools.VersionIsAlpha(version)) website = "https://unity3d.com/unity/alpha/" + version;
370370

371-
// fix unity server problem, page says 404 found if no url params
371+
// fix unity server problem, some pages says 404 found if no url params
372372
website += "?unitylauncherpro";
373373

374-
// download html
375-
string sourceHTML = client.DownloadString(website);
374+
string sourceHTML = null;
375+
// need to catch 404 error
376+
try
377+
{
378+
// download page html
379+
sourceHTML = client.DownloadString(website);
380+
}
381+
catch (WebException e)
382+
{
383+
Console.WriteLine(e.Message);
384+
return null;
385+
}
386+
376387
string[] lines = sourceHTML.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
377388

378389
// patch version download assistant finder

0 commit comments

Comments
 (0)