void UpdateWorker() { try { CheckUpdates(); } catch (WebException ex) { Finish(false, ex, null); return; } catch (Exception ex) { ErrorHandler2.LogError("UpdateCheckTask.CheckUpdates", ex); Finish(false, null, "&cUpdate check failed"); return; } Finish(true, null, null); }
static void ProcessZipEntry(string filename, byte[] data, ZipEntry entry) { string path = Path.Combine(Program.AppDirectory, "CS_Update"); path = Path.Combine(path, Path.GetFileName(filename)); File.WriteAllBytes(path, data); try { File.SetLastWriteTimeUtc(path, PatchTime); } catch (IOException ex) { ErrorHandler2.LogError("I/O exception when trying to set modified time for: " + filename, ex); } catch (UnauthorizedAccessException ex) { ErrorHandler2.LogError("Permissions exception when trying to set modified time for: " + filename, ex); } }
void DisplayWebException(WebException ex, string action) { ErrorHandler2.LogError(action, ex); bool sslCertError = ex.Status == WebExceptionStatus.TrustFailure || (ex.Status == WebExceptionStatus.SendFailure && OpenTK.Configuration.RunningOnMono); if (ex.Status == WebExceptionStatus.Timeout) { string text = "&cTimed out when connecting to classicube.net."; SetStatus(text); } else if (ex.Status == WebExceptionStatus.ProtocolError) { HttpWebResponse response = (HttpWebResponse)ex.Response; int errorCode = (int)response.StatusCode; string description = response.StatusDescription; string text = "&cclassicube.net returned: (" + errorCode + ") " + description; SetStatus(text); } else if (ex.Status == WebExceptionStatus.NameResolutionFailure) { string text = "&cUnable to resolve classicube.net" + Environment.NewLine + "Are you connected to the internet?"; SetStatus(text); } else if (sslCertError) { string text = "&cFailed to validate SSL certificate"; SetStatus(text); ShowSSLErrorWidgets(); } else { string text = "&c" + ex.Status; SetStatus(text); } }