Inheritance: SystemException
Exemplo n.º 1
0
        internal void ProcessValidationResults(ValidationResults results)
        {
            if (results == null)
                throw new ArgumentNullException("results");

            if (results.Errors != null && results.Errors.Count == 0)
                return;

            string errorMessage = string.Empty;

            foreach (ValidationError error in results.Errors)
            {
                errorMessage += error.Message;
                errorMessage += "\n";
            }

            ValidationException exception = new ValidationException(errorMessage);

            Tracer.TraceException(exception);
            _structuredTracer.WorkflowValidationError(Guid.Empty);
            throw exception;
        }
        internal static bool TryWrapSupportedVersionException(string filePath, Exception e, out Exception newException)
        {
            // We replace the exception, rather than simply wrapping it, because the activation error page highlights 
            // the innermost exception, and we want that  exception to clearly show which file is the culprit.
            // Of course, if the exception has an inner exception, that will still get highlighted instead.
            // Also, for Xaml and XmlException, we don't propagate the line info, because the exception message already contains it.
            if (e is XmlException)
            {
                newException = new XmlException(SR.ExceptionLoadingSupportedVersion(filePath, e.Message), e.InnerException);
                return true;
            }

            if (e is XamlException)
            {
                newException = new XamlException(SR.ExceptionLoadingSupportedVersion(filePath, e.Message), e.InnerException);
                return true;
            }

            if (e is InvalidWorkflowException)
            {
                newException = new InvalidWorkflowException(SR.ExceptionLoadingSupportedVersion(filePath, e.Message), e.InnerException);
                return true;
            }

            if (e is ValidationException)
            {
                newException = new ValidationException(SR.ExceptionLoadingSupportedVersion(filePath, e.Message), e.InnerException);
                return true;
            }

            newException = null;
            return false;
        }
Exemplo n.º 3
0
        private void ValidateWorkflowInternal(Activity workflow, string runtimeAssembly, PSWorkflowValidationResults validationResults)
        {
            Tracer.WriteMessage(Facility + "Validating a workflow.");
            _structuredTracer.WorkflowValidationStarted(Guid.Empty);

            ValidationSettings validationSettings = new ValidationSettings
            {
                AdditionalConstraints =
                    {                             
                        { typeof(Activity), new List<Constraint> { ValidateActivitiesConstraint(runtimeAssembly, validationResults)} }
                    }
            };

            try
            {
                validationResults.Results = ActivityValidationServices.Validate(workflow, validationSettings);
            }
            catch (Exception e)
            {
                Tracer.TraceException(e);
                ValidationException exception = new ValidationException(Resources.ErrorWhileValidatingWorkflow, e);
                throw exception;
            }

            _structuredTracer.WorkflowValidationFinished(Guid.Empty);

        }
Exemplo n.º 4
0
		internal void ProcessValidationResults(ValidationResults results)
		{
			if (results != null)
			{
				if (results.Errors == null || results.Errors.Count != 0)
				{
					string empty = string.Empty;
					foreach (ValidationError error in results.Errors)
					{
						empty = string.Concat(empty, error.Message);
						empty = string.Concat(empty, "\n");
					}
					ValidationException validationException = new ValidationException(empty);
					PSWorkflowValidator.Tracer.TraceException(validationException);
					PSWorkflowValidator._structuredTracer.WorkflowValidationError(Guid.Empty);
					throw validationException;
				}
				else
				{
					return;
				}
			}
			else
			{
				throw new ArgumentNullException("results");
			}
		}