Пример #1
0
        public static void ShowException(string messagem, Exception exception, string title = null)
        {
            MessageBoxException messageBoxException = new MessageBoxException();

            if (title != null)
            {
                messageBoxException.Text = title;
            }

            messageBoxException.lblMsg.Text       = messagem;
            messageBoxException.txtException.Text = exception.Message;
            if (exception.InnerException != null)
            {
                messageBoxException.txtInner.Text = exception.InnerException.Message
                                                    + "\n" + exception.InnerException.StackTrace;
            }

            messageBoxException.txtStack.Text = exception.StackTrace;
            messageBoxException.ShowDialog();
        }
Пример #2
0
        /// <summary>
        /// Exibe somente a mensagem que a exceção lançou e gera log da execeção.
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="message"></param>
        /// <param name="title"></param>
        public static void ExceptionMessageDetails(Exception ex, string message, string title = null)
        {
            if (ex == null)
            {
                ex = new Exception();
            }
            var split  = (ex.Message + "").Split('.');
            var newMsg = "";

            foreach (var item in split)
            {
                newMsg += item + "\n";
            }

            string msg  = string.Format("{0}\n{1}\n{2}", message, newMsg, "Verifique o arquivo de logs na pasta its");
            var    logs = "C:\\logs\\its\\excecoes";

            FileManagerIts.CreateDirectory(logs);
            FileManagerIts.AppendTextFileException(logs + "\\" + ex.GetType()
                                                   + "-" + DateTime.Now.ToString("dd-MM-yyyy") + ".txt", ex);

            MessageBoxException.ShowException(message, ex, title);
        }