Beispiel #1
0
        private static ExprValidationPropertyException GetSuggestionException(StreamTypesException ex)
        {
            var suggestion = GetSuggestion(ex);
            if (suggestion != null) {
                return new ExprValidationPropertyException(ex.Message + suggestion);
            }

            return new ExprValidationPropertyException(ex.Message);
        }
        private static ExprValidationPropertyException GetSuggestionException(StreamTypesException ex)
        {
            string suggestion = GetSuggestion(ex);

            if (suggestion != null)
            {
                return(new ExprValidationPropertyException(ex.Message + suggestion));
            }
            else
            {
                return(new ExprValidationPropertyException(ex.Message));
            }
        }
Beispiel #3
0
        private static string GetSuggestion(StreamTypesException ex)
        {
            var suggestion = ex?.OptionalSuggestion;
            if (suggestion == null) {
                return null;
            }

            if (suggestion.First > LevenshteinDistance.ACCEPTABLE_DISTANCE) {
                return null;
            }

            return " (did you mean '" + ex.OptionalSuggestion.Second + "'?)";
        }
        private static string GetSuggestion(StreamTypesException ex)
        {
            if (ex == null)
            {
                return(null);
            }
            var optionalSuggestion = ex.OptionalSuggestion;

            if (optionalSuggestion == null)
            {
                return(null);
            }
            if (optionalSuggestion.First > LevenshteinDistance.ACCEPTABLE_DISTANCE)
            {
                return(null);
            }
            return(" (did you mean '" + optionalSuggestion.Second + "'?)");
        }
Beispiel #5
0
        private static ExprValidationPropertyException GetSuggestionExceptionSecondStep(
            string propertyNameCandidate,
            StreamTypesException typeExceptionOne,
            StreamTypesException typeExceptionTwo)
        {
            var suggestionOne = GetSuggestion(typeExceptionOne);
            var suggestionTwo = GetSuggestion(typeExceptionTwo);
            if (suggestionOne != null) {
                return new ExprValidationPropertyException(typeExceptionOne.Message + suggestionOne);
            }

            if (suggestionTwo != null) {
                return new ExprValidationPropertyException(typeExceptionTwo.Message + suggestionTwo);
            }

            // fail to resolve
            return new ExprValidationPropertyException(
                "Failed to resolve property '" +
                propertyNameCandidate +
                "' to a stream or nested property in a stream");
        }