/// <summary>
        /// Conversion between an error internal representation and ErrorRecord
        /// </summary>
        /// <param name="error">internal error object</param>
        /// <returns>corresponding ErrorRecord instance</returns>
        private static ErrorRecord GenerateErrorRecord(FormattingError error)
        {
            ErrorRecord        errorRecord        = null;
            string             msg                = null;
            MshExpressionError mshExpressionError = error as MshExpressionError;

            if (mshExpressionError != null)
            {
                errorRecord = new ErrorRecord(
                    mshExpressionError.result.Exception,
                    "mshExpressionError",
                    ErrorCategory.InvalidArgument,
                    mshExpressionError.sourceObject);

                msg = StringUtil.Format(FormatAndOut_format_xxx.MshExpressionError,
                                        mshExpressionError.result.ResolvedExpression.ToString());
                errorRecord.ErrorDetails = new ErrorDetails(msg);
            }

            StringFormatError formattingError = error as StringFormatError;

            if (formattingError != null)
            {
                errorRecord = new ErrorRecord(
                    formattingError.exception,
                    "formattingError",
                    ErrorCategory.InvalidArgument,
                    formattingError.sourceObject);

                msg = StringUtil.Format(FormatAndOut_format_xxx.FormattingError,
                                        formattingError.formatString);
                errorRecord.ErrorDetails = new ErrorDetails(msg);
            }
            return(errorRecord);
        }
Example #2
0
 internal void LogMshExpressionFailedResult(MshExpressionResult result, object sourceObject)
 {
     if (this.formatErrorPolicy.ShowErrorsAsMessages)
     {
         MshExpressionError item = new MshExpressionError {
             result = result,
             sourceObject = sourceObject
         };
         this.formattingErrorList.Add(item);
     }
 }
Example #3
0
 internal void LogMshExpressionFailedResult(MshExpressionResult result, object sourceObject)
 {
     if (this.formatErrorPolicy.ShowErrorsAsMessages)
     {
         MshExpressionError item = new MshExpressionError {
             result       = result,
             sourceObject = sourceObject
         };
         this.formattingErrorList.Add(item);
     }
 }
        /// <summary>
        /// log a failed evaluation of an MshExpression
        /// </summary>
        /// <param name="result">MshExpressionResult containing the failed evaluation data</param>
        /// <param name="sourceObject">object used to evaluate the MshExpression</param>
        internal void LogMshExpressionFailedResult(MshExpressionResult result, object sourceObject)
        {
            if (!_formatErrorPolicy.ShowErrorsAsMessages)
            {
                return;
            }
            MshExpressionError error = new MshExpressionError();

            error.result       = result;
            error.sourceObject = sourceObject;
            _formattingErrorList.Add(error);
        }
Example #5
0
        private static ErrorRecord GenerateErrorRecord(FormattingError error)
        {
            ErrorRecord        record  = null;
            string             message = null;
            MshExpressionError error2  = error as MshExpressionError;

            if (error2 != null)
            {
                record              = new ErrorRecord(error2.result.Exception, "mshExpressionError", ErrorCategory.InvalidArgument, error2.sourceObject);
                message             = StringUtil.Format(FormatAndOut_format_xxx.MshExpressionError, error2.result.ResolvedExpression.ToString());
                record.ErrorDetails = new ErrorDetails(message);
            }
            StringFormatError error3 = error as StringFormatError;

            if (error3 != null)
            {
                record              = new ErrorRecord(error3.exception, "formattingError", ErrorCategory.InvalidArgument, error3.sourceObject);
                message             = StringUtil.Format(FormatAndOut_format_xxx.FormattingError, error3.formatString);
                record.ErrorDetails = new ErrorDetails(message);
            }
            return(record);
        }
Example #6
0
 /// <summary>
 /// log a failed evaluation of an MshExpression
 /// </summary>
 /// <param name="result">MshExpressionResult containing the failed evaluation data</param>
 /// <param name="sourceObject">object used to evaluate the MshExpression</param>
 internal void LogMshExpressionFailedResult(MshExpressionResult result, object sourceObject)
 {
     if (!_formatErrorPolicy.ShowErrorsAsMessages)
         return;
     MshExpressionError error = new MshExpressionError();
     error.result = result;
     error.sourceObject = sourceObject;
     _formattingErrorList.Add(error);
 }