BF2Statistics.ExceptionHandler.GenerateExceptionLog C# (CSharp) Method

GenerateExceptionLog() public static method

Generates a trace log for an exception. If an exception is thrown here, The error will automatically be logged in the programs error log
public static GenerateExceptionLog ( Exception E ) : void
E System.Exception The exception we are logging
return void
        public static void GenerateExceptionLog(Exception E)
        {
            string FileName = GenerateFileName();
            GenerateExceptionLog(FileName, E);
        }

Same methods

ExceptionHandler::GenerateExceptionLog ( Exception E, string &FileName ) : void
ExceptionHandler::GenerateExceptionLog ( string FileName, Exception E ) : void

Usage Example

Example #1
0
        /// <summary>
        /// Event called when an update file has completed its download
        /// </summary>
        private static void Wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            // Close task form, and unregister for updates
            TaskForm.Cancelled -= TaskForm_Cancelled;
            TaskForm.CloseForm();
            IsDownloading = false;

            // Dispose webclient
            Web.Dispose();

            // If we cancelled, stop here
            if (e.Cancelled)
            {
                // Delete junk files
                if (File.Exists(UpdateFileLocation))
                {
                    File.Delete(UpdateFileLocation);
                }

                return;
            }

            // Try to start the isntaller
            try
            {
                // Extract setup.exe
                string exFile = Path.Combine(Paths.DocumentsFolder, "setup.exe");
                using (ZipArchive file = ZipFile.Open(UpdateFileLocation, ZipArchiveMode.Read))
                {
                    ZipArchiveEntry setupFile = file.Entries.FirstOrDefault(x => x.FullName == "setup.exe");
                    if (setupFile != null)
                    {
                        // Extract and start the new update installer
                        setupFile.ExtractToFile(exFile, true);
                        Process installer = Process.Start(exFile);
                        installer.WaitForInputIdle();
                    }
                    else
                    {
                        MessageBox.Show(
                            "The Setup.exe file appears to be missing from the update archive! You will need to manually apply the update.",
                            "Installation Error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error
                            );
                    }
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(
                    "An Occured while trying to install the new update. You will need to manually apply the update."
                    + Environment.NewLine.Repeat(1) + "Error Message: " + Ex.Message,
                    "Installation Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
                ExceptionHandler.GenerateExceptionLog(Ex);
            }

            // Exit the application
            Application.Exit();
        }
All Usage Examples Of BF2Statistics.ExceptionHandler::GenerateExceptionLog