示例#1
0
        private SkExceptionHandleAction GetExceptionActionFromConfig(string config, SkExceptionHandleAction defaultAction)
        {
            var actionStr = ConfigurationManager.AppSettings[config];

            if (!string.IsNullOrEmpty(actionStr))
            {
                SkExceptionHandleAction action;
                if (Enum.TryParse(actionStr, out action))
                {
                    return(action);
                }

                return(defaultAction);
            }

            return(defaultAction);
        }
示例#2
0
        private static void HandleExceptioin(Exception ex, SkExceptionHandleAction action)
        {
            //No action
            if (action == SkExceptionHandleAction.None)
            {
                return;
            }

            //log exception
            if (action == SkExceptionHandleAction.LogAndRethrow)
            {
                var logger = SkServiceLocator.Get <SkLoggerBase>();
                if (logger != null)
                {
                    logger.LogError(ex);
                }
            }

            // throw current exception
            if (action == SkExceptionHandleAction.Rethrow || action == SkExceptionHandleAction.LogAndRethrow)
            {
                throw ex;
            }
        }