Пример #1
0
        /// <summary>
        /// Handles exception and returns action result to take.
        /// </summary>
        /// <param name="ex">Exception</param>
        /// <returns></returns>
        public virtual ExceptionResult Exception(Exception ex)
        {
            ExceptionResult result = null;

            if (ex.IsNotNull())
            {
                ExceptionInformation informationAbouException = new ExceptionInformation(ex);
                if (this.CaterpillarMvcHttpRequest.Browser != null)
                {
                    informationAbouException.ExtraInformation = this.CaterpillarMvcHttpRequest.CaterpillarRequest.ConvertBrowserInformationToDictionary(this.CaterpillarMvcHttpRequest.Browser);
                }
                informationAbouException.ClientIp = this.CaterpillarMvcHttpRequest.GetClientIpAddress();
                if (this.User != null)
                {
                    informationAbouException.UserCultureSettings = this.User.Culture.TwoLetterISOLanguageName;
                    informationAbouException.UserId = this.User.UserId;
                }
                ObjectListCollection objectIds = ApplicationFoundation.Current.ExceptionManager.Log(informationAbouException);
                if (objectIds != null && objectIds.Count > 0)
                {
                    this.ErrorId = objectIds.Where(_id => _id.GetType() == typeof(int) || _id.GetType() == typeof(Guid)).FirstOrDefault();
                }
                this.Error = LanguageStrings.GeneralExceptionMessage;
                result     = new ExceptionResult(ex);
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Logs exception to storages provided by ExceptionLoggingProviders
        /// </summary>
        /// <param name="informationAboutException">Exception to log.</param>
        /// <returns>Returns all id list from all exception providers in object list collection.</returns>
        public ObjectListCollection Log(ExceptionInformation informationAboutException)
        {
            if (!this.IsConfigured)
            {
                CoreLevelException.Throw(LanguageStrings.ExceptionManagerIsNotConfiguredMessage);
            }

            ObjectListCollection objectIds = new ObjectListCollection();
            object tempId = null;

            foreach (ExceptionLoggingProviderBase eachExceptionLogger in ExceptionLoggingProviders)
            {
                tempId = eachExceptionLogger.Log <object>(informationAboutException);
                objectIds.Add(tempId);
            }

            return(objectIds);
        }