Exemplo n.º 1
0
        public ApplicationMessage GetMessage(BussinessException bex)
        {
            var appMessage = new ApplicationMessage();

            appMessage.Message = "Message not found!";

            if (messages.ContainsKey(bex.ExceptionId))
            {
                appMessage = messages[bex.ExceptionId];
            }

            return(appMessage);
        }
Exemplo n.º 2
0
        public void Process(Exception ex)
        {
            var bex = new BussinessException();

            if (ex.GetType() == typeof(BussinessException))
            {
                bex = (BussinessException)ex;
            }
            else
            {
                bex = new BussinessException(0, ex);
            }

            ProcessBussinesException(bex);
        }
Exemplo n.º 3
0
        private void ProcessBussinesException(BussinessException bex)
        {
            var today   = DateTime.Now.ToString("YYYYMMdd");
            var logName = PATH + today + "_" + "log.txt";

            var message = bex.Message + "\n" + bex.StackTrace + "\n";

            if (bex.InnerException != null)
            {
                message += bex.InnerException.Message + "\n" + bex.InnerException.StackTrace;
            }

            using (StreamWriter w = File.AppendText(logName))
            {
                Log(bex.Message, w);
            }

            bex.AppMessage = GetMessage(bex);

            throw bex;
        }