internal ParseException(ParseExceptionKind kind, Token token, String expression)
            : base(secretMasker: null, message: String.Empty)
        {
            Expression = expression;
            Kind       = kind;
            RawToken   = token?.RawValue;
            TokenIndex = token?.Index ?? 0;
            String description;

            switch (kind)
            {
            case ParseExceptionKind.ExceededMaxDepth:
                description = $"Exceeded max expression depth {ExpressionConstants.MaxDepth}";
                break;

            case ParseExceptionKind.ExceededMaxLength:
                description = $"Exceeded max expression length {ExpressionConstants.MaxLength}";
                break;

            case ParseExceptionKind.TooFewParameters:
                description = "Too few parameters supplied";
                break;

            case ParseExceptionKind.TooManyParameters:
                description = "Too many parameters supplied";
                break;

            case ParseExceptionKind.UnexpectedEndOfExpression:
                description = "Unexpected end of expression";
                break;

            case ParseExceptionKind.UnexpectedSymbol:
                description = "Unexpected symbol";
                break;

            case ParseExceptionKind.UnrecognizedFunction:
                description = "Unrecognized function";
                break;

            case ParseExceptionKind.UnrecognizedNamedValue:
                description = "Unrecognized named-value";
                break;

            default:     // Should never reach here.
                throw new Exception($"Unexpected parse exception kind '{kind}'.");
            }

            if (token == null)
            {
                Message = description;
            }
            else
            {
                Message = $"{description}: '{RawToken}'. Located at position {TokenIndex + 1} within expression: {Expression}";
            }
        }
Exemplo n.º 2
0
        internal ParseException(ParseExceptionKind kind, Token token, String expression)
        {
            Expression = expression;
            Kind       = kind;
            RawToken   = token?.RawValue;
            TokenIndex = token?.Index ?? 0;
            String description;

            switch (kind)
            {
            case ParseExceptionKind.ExceededMaxDepth:
                description = $"Exceeded max expression depth {ExpressionConstants.MaxDepth}.";
                break;

            case ParseExceptionKind.ExceededMaxLength:
                description = $"Exceeded max expression length {ExpressionConstants.MaxLength}.";
                break;

            case ParseExceptionKind.ExpectedPropertyName:
                description = "Expected property name to follow deference operator";
                break;

            case ParseExceptionKind.ExpectedStartParameter:
                description = "Expected '(' to follow function";
                break;

            case ParseExceptionKind.UnclosedFunction:
                description = "Unclosed function";
                break;

            case ParseExceptionKind.UnclosedIndexer:
                description = "Unclosed indexer";
                break;

            case ParseExceptionKind.UnexpectedSymbol:
                description = "Unexpected symbol";
                break;

            case ParseExceptionKind.UnrecognizedValue:
                description = "Unrecognized value";
                break;

            default:     // Should never reach here.
                throw new Exception($"Unexpected parse exception kind '{kind}'.");
            }

            if (token == null)
            {
                Message = $"{description}. For more help, refer to https://go.microsoft.com/fwlink/?linkid=842996";
            }
            else
            {
                // TODO: loc
                Message = $"{description}: '{RawToken}'. Located at position {TokenIndex + 1} within expression: {Expression}. For more help, refer to https://go.microsoft.com/fwlink/?linkid=842996";
            }
        }
Exemplo n.º 3
0
        internal ParseException(ParseExceptionKind kind, Token token, String expression)
        {
            Expression = expression;
            Kind       = kind;
            RawToken   = token.RawValue;
            TokenIndex = token.Index;
            String description;

            // TODO: LOC
            switch (kind)
            {
            case ParseExceptionKind.ExpectedPropertyName:
                description = "Expected property name to follow deference operator";
                break;

            case ParseExceptionKind.ExpectedStartParameter:
                description = "Expected '(' to follow function";
                break;

            case ParseExceptionKind.UnclosedFunction:
                description = "Unclosed function";
                break;

            case ParseExceptionKind.UnclosedIndexer:
                description = "Unclosed indexer";
                break;

            case ParseExceptionKind.UnexpectedSymbol:
                description = "Unexpected symbol";
                break;

            case ParseExceptionKind.UnrecognizedValue:
                description = "Unrecognized value";
                break;

            default:     // Should never reach here.
                throw new Exception($"Unexpected parse exception kind '{kind}'.");
            }

            Int32 position = token.Index + 1;

            // TODO: loc
            Message = $"{description}: '{RawToken}'. Located at position {position} within condition expression: {Expression}";
        }