Ejemplo n.º 1
0
        private static void ThrowBadUserCodeException(string fullCode, CompilerResults cr)
        {
            StringBuilder exceptionMessage = new StringBuilder();
            StringBuilder allErrors        = new StringBuilder();

            BadUserCodeException.BadFieldDescription badField = null;
            string errorMessage = null;

            exceptionMessage.Append("Failed to process log fields. There must be an error in format's configuration. ");

            foreach (CompilerError err in cr.Errors)
            {
                if (err.IsWarning)
                {
                    continue;
                }

                exceptionMessage.AppendLine(err.ErrorText);
                allErrors.AppendFormat("Line {0} Column {1}: ({2}) {3}{4}",
                                       err.Line, err.Column, err.ErrorNumber, err.ErrorText, Environment.NewLine);
                errorMessage = err.ErrorText;

                int            globalErrorPos;
                UserCode.Entry?userCodeEntry;
                UserCode.FindErrorLocation(fullCode, err, out globalErrorPos, out userCodeEntry);
                if (userCodeEntry != null)
                {
                    badField = new BadUserCodeException.BadFieldDescription(
                        userCodeEntry.Value.FieldName, globalErrorPos - userCodeEntry.Value.Index);
                }

                break;
            }

            throw new BadUserCodeException(exceptionMessage.ToString(), fullCode, errorMessage, allErrors.ToString(), badField);
        }