Esempio n. 1
0
        /// <summary>
        /// Handle error. <br/>
        /// Write log, bug report and open window to show error.
        /// </summary>
        public void HandleError()
        {
            ErrorOccured view = new ErrorOccured(_error);

            view.ShowDialog();

            using (var stream = new StreamWriter($"{_dirPath}\\{DateTime.Now:MMddyyHHmssfff}.log", false))
            {
                StringBuilder errorData = new StringBuilder();
                errorData.Append($"Date: {DateTime.Now:G} \n");
                errorData.Append($"Message: {_error.Message} \n");
                errorData.Append($"Class: {_error.GetType().Name} \n");
                errorData.Append($"Stack trace: {_error.StackTrace} \n");
                errorData.Append($"HResult: {_error.HResult}");

                _log.AppendLogMessage(_error.Message, "EXCP");
                stream.Write(errorData.ToString());
            }
        }