Beispiel #1
0
        public ApplicationErrorData CreateApplicationError(string errorTypeSystemName)
        {
            if (errorTypeSystemName == null)
            {
                throw new ArgumentNullException("errorTypeSystemName");
            }
            var error = new ApplicationErrorData(this, errorTypeSystemName);

            error.TypeCode = HashHelper.GetInt32Dig5(errorTypeSystemName);
            PrepareEventAfterCreation(error);
            return(error);
        }
        public ApplicationErrorData GetApplicationErrorData(IComponentControl componentControl, Exception exception, string errorName)
        {
            var typeSystemName  = GetTypeSystemName(errorName, exception);
            var typeDisplayName = GetTypeDisplayName(errorName, exception);

            var errorData = new ApplicationErrorData(componentControl, typeSystemName)
            {
                TypeDisplayName = typeDisplayName
            };

            if (exception != null)
            {
                errorData.Message  = GetMessage(exception);
                errorData.Stack    = GetFullStackTrace(exception);
                errorData.TypeCode = GetExceptionTypeCode(exception);

                var allMessages       = GetAllMessages(exception);
                var ignoreFullMessage = allMessages == null || exception.InnerException == null || allMessages == errorData.Message;
                if (!ignoreFullMessage)
                {
                    errorData.SetProperty(ExtentionPropertyName.AllMessages, allMessages);
                }
                var internalAppException = exception as ApplicationErrorException;
                if (internalAppException != null)
                {
                    errorData.Properties.CopyFrom(internalAppException.Properties);
                }

                foreach (var dataKey in exception.Data.Keys)
                {
                    var key   = dataKey.ToString();
                    var value = exception.Data[dataKey];
                    if (errorData.Properties.HasKey(key))
                    {
                        errorData.Properties[key].Value = value;
                    }
                    else
                    {
                        errorData.Properties.Set(key, value);
                    }
                }
            }
            return(errorData);
        }