예제 #1
0
        /// <summary>
        /// BaseException 日志
        /// </summary>
        /// <param name="ex"></param>
        public static void BaseExceptionLog(BaseException ex)
        {
            if (!Config.IsDebug)
            {
                return;
            }


            using (var traceItem = new SenparcTraceItem(_logEndActon, "BaseException"))
            {
                traceItem.Log(ex.GetType().Name);
                traceItem.Log("Message:{0}", ex.Message);
                traceItem.Log("StackTrace:{0}", ex.StackTrace);

                if (ex.InnerException != null)
                {
                    traceItem.Log("InnerException:{0}", ex.InnerException.Message);
                    traceItem.Log("InnerException.StackTrace:{0}", ex.InnerException.StackTrace);
                }

                if (OnBaseExceptionFunc != null)
                {
                    try
                    {
                        OnBaseExceptionFunc(ex);
                    }
                    catch
                    {
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// WeixinException 日志
        /// </summary>
        /// <param name="ex"></param>
        public static void BaseExceptionLog(BaseException ex)
        {
            if (!Config.IsDebug)
            {
                return;
            }

            LogBegin("[[BaseException]]");
            Log(ex.GetType().Name);
            Log("Message:{0}", ex.Message);
            Log("StackTrace:{0}", ex.StackTrace);
            if (ex.InnerException != null)
            {
                Log("InnerException:{0}", ex.InnerException.Message);
                Log("InnerException.StackTrace:{0}", ex.InnerException.StackTrace);
            }

            if (OnBaseExceptionFunc != null)
            {
                try
                {
                    OnBaseExceptionFunc(ex);
                }
                catch
                {
                }
            }

            LogEnd();
        }
예제 #3
0
 public static void LogException(BaseException baseException)
 {
     using var streamWriter = new StreamWriter(ProjectConstants.ExceptionLoggerFilePath, true);
     streamWriter.WriteLine("-----------------------------------------------------------------------------");
     streamWriter.WriteLine("Date : " + DateTime.Now.ToString(ProjectConstants.LoggerDateTimeFormat));
     streamWriter.WriteLine(baseException.GetType().FullName);
     streamWriter.WriteLine("Message : " + baseException.Message);
     streamWriter.WriteLine("Wrong line : " + baseException.Line);
     streamWriter.WriteLine();
 }
 /// <summary>
 /// To the simple exception information.
 /// </summary>
 /// <param name="exception">The exception.</param>
 /// <param name="eventKey">The event key.</param>
 /// <returns>
 /// Beyova.Diagnostic.ExceptionInfo.
 /// </returns>
 public static ExceptionInfo ToSimpleExceptionInfo(this BaseException exception, string eventKey = null)
 {
     return(exception == null ? null : new ExceptionInfo
     {
         ExceptionType = exception.GetType()?.GetFullName(),
         Message = exception.Hint != null ? exception.Hint.Message : exception.Message,
         Code = exception.Hint != null ? new ExceptionCode
         {
             Major = exception.Code.Major,
             Minor = exception.Hint.HintCode
         } : exception.Code,
         EventKey = eventKey,
         Data = (exception.Hint != null && exception.Hint.CauseObjects != null) ? JToken.FromObject(exception.Hint.CauseObjects) : exception.ReferenceData
     });
 }
예제 #5
0
        public static JsonResult HandleExceptions(this HttpResponse response, BaseException e)
        {
            var className = e.GetType().Name;

            switch (className)
            {
            case "UnprocessableException":
                return(response.UnprocessableEntity(ExceptionHandlerHelper.ExceptionMessage(e)));

            case "BadRequestException":
                return(response.BadRequest(ExceptionHandlerHelper.ExceptionMessage(e)));

            case "NotFoundException":
                return(response.NotFound(ExceptionHandlerHelper.ExceptionMessage(e)));

            default:
                return(response.InternalServerError());
            }
        }
 private static decimal GetAmountRefounded(BaseException ex)
 {
     return(ex.GetType().Name.Equals(nameof(PendingTransferException))
         ? ((PendingTransferException)ex).AmountRefounded
         : decimal.Zero);
 }
예제 #7
0
        public static void LogException(BaseException ex, string className, string methodName)
        {
            if (ex.InsertedLog)
            {
                return;
            }
            ex.InsertedLog = true;
            string curentUsername = Security.BUser.CurrentUser.UserName;

            if (curentUsername.ToLower().Equals("nunituser"))
            {
                return;
            }

            if (IsBusinessErrorLogEnable)
            {
                if (ex is InvalidPersianDateException)
                {
                    businessErrorlogger.Error(curentUsername, className, methodName, "GTS.Clock.Business", " InvalidPersianDateException --> " + ((InvalidPersianDateException)ex).GetLogMessage(), ex);
                }
                else if (ex is UIBaseException)
                {
                    businessErrorlogger.Error(curentUsername, className, methodName, "GTS.Clock.Business", String.Format("{0} --> {1}", ex.GetType().Name, ((UIBaseException)ex).GetLogMessage()), ex);
                }
                else
                {
                    businessErrorlogger.Error(curentUsername, className, methodName, "GTS.Clock.Business", String.Format("{0} --> {1}", ex.GetType().Name, ((BaseException)ex).GetLogMessage()), ex);
                }
            }
        }
예제 #8
0
        protected void LogException(BaseException ex, string className, string methodName, string currentUserName, bool isBusinessLogEnable)
        {
            if (ex.InsertedLog)
            {
                return;
            }
            ex.InsertedLog = true;
            string curentUsername = currentUserName;

            if (curentUsername.ToLower().Equals("nunituser"))
            {
                return;
            }

            if (isBusinessLogEnable)
            {
                if (ex is InvalidPersianDateException)
                {
                    businessErrorlogger.Error(curentUsername, className, methodName, "BaseGTSBusiness", " InvalidPersianDateException --> " + ((InvalidPersianDateException)ex).GetLogMessage(), ex);
                }
                else if (ex is UIBaseException)
                {
                    businessErrorlogger.Error(curentUsername, className, methodName, "BaseGTSBusiness", String.Format("{0} --> {1}", ex.GetType().Name, ((UIBaseException)ex).GetLogMessage()), ex);
                }
                else
                {
                    businessErrorlogger.Error(curentUsername, className, methodName, "BaseGTSBusiness", String.Format("{0} --> {1}", ex.GetType().Name, ((BaseException)ex).GetLogMessage()), ex);
                }
            }
        }
 public static void Throw(BaseException e)
 {
     e.GetType();
 }