Beispiel #1
0
        public CustomAppException HandleException(string funcName, Exception exception, string userID)
        {
            CustomAppException customException = new CustomAppException();

            customException.ErrorSource  = funcName;
            customException.ErrorMessage = exception.Message;
            customException.StackTrace   = exception.StackTrace;
            return(HandleCustomException(funcName, customException, userID));
        }
Beispiel #2
0
        public CustomAppException HandleCustomException(string funcName, CustomAppException customException, string userID)
        {
            CustomAppException ex = new CustomAppException();

            ex.ErrorMessage = customException.ErrorMessage;
            ex.ErrorSource  = customException.ErrorSource;
            ex.StackTrace   = customException.StackTrace;
            LogException(customException, userID);
            return(ex);
        }
Beispiel #3
0
 public ActionResult Error(string errorCode = "", string errMessage = "", string actionPath = "")
 {
     if (!string.IsNullOrWhiteSpace(errMessage))
     {
         var ajaxException = new CustomAppException();
         ajaxException.ErrorID      = errorCode;
         ajaxException.ErrorMessage = errMessage;
         ajaxException.ErrorSource  = actionPath;
         logger.Error("Error: " + ajaxException, "Error occured in Controller: HomePage, Action: Error");
     }
     return(View("Error"));
 }
Beispiel #4
0
        public bool LogException(CustomAppException customizedException, string userID)
        {
            System.IO.StreamWriter objStreamWriter = null;
            bool status = false;

            try
            {
                string filename     = DateTime.Today.ToString("yyyyMMdd");
                string ErrorLogPath = null;

                ErrorLogPath = GetPath(filename);

                if (!Directory.Exists(ErrorLogPath))
                {
                    Directory.CreateDirectory(ErrorLogPath);
                }
                var    currentDateTime = DateTime.Now;
                string errorFilename   = currentDateTime.ToString("ddMMyyyy _hh_mm_ss");

                objStreamWriter = new System.IO.StreamWriter(ErrorLogPath + errorFilename + ".txt", true);

                objStreamWriter.WriteLine("UserID: " + userID);
                objStreamWriter.WriteLine("ErrorSource : " + customizedException.ErrorSource);
                objStreamWriter.WriteLine("ErrorMessage: " + customizedException.ErrorMessage);
                objStreamWriter.WriteLine("StackTrace: " + customizedException.StackTrace);

                status = true;
            }
            finally
            {
                objStreamWriter.Flush();
                objStreamWriter.Close();
                objStreamWriter.Dispose();
            }

            return(status);
        }