8000 [ExpressionLanguage]: Lexer should provide information to malformed file and/or expression on SyntaxError · Issue #19445 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[ExpressionLanguage]: Lexer should provide information to malformed file and/or expression on SyntaxError #19445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
k0pernikus opened this issue Jul 27, 2016 · 2 comments

Comments

@k0pernikus
Copy link
Contributor
k0pernikus commented Jul 27, 2016

If a malformed expression syntax is provided in a yaml service config, e.g:

http.request_factory:
    class: Dreamlines\Http\RequestFactory
    arguments:
        - '@ba.endpoint_provider'
        - "@=service(rba.context.factory').create()"

(The r should be a ')

The SyntaxError looks like:

[Symfony\Component\ExpressionLanguage\SyntaxError]  
Unexpected character "'" around position 36. 

There's no information provided what file caused the error, nor the line, nor the faulty expression is echoed so I had to start a xdebug session to find out the yml file in error.

I would have expected the information to read like:

[Symfony\Component\ExpressionLanguage\SyntaxError]  
Unexpected character "'" around position 36 in expression "@=service(rba.context.factory').create()" in "path/to/my/service.yml" on line 39.
@stof
Copy link
Member
stof commented Jul 27, 2016

The ExpressionLanguage has no knowledge about about where the expression string was created (and adding such context would be a nightmare actually).
But adding the expression itself in the error message would indeed already help (note that the expression is only service(rba.context.factory').create(); @= is not part of it, it is only the syntax the DI YamlFileLoader uses to know that the argument is an expression)

@k0pernikus
Copy link
Contributor Author

@stof I will work on a PR to add the expression text in the exception.

8000

stof pushed a commit to stof/symfony that referenced this issue Mar 31, 2017
fabpot added a commit that referenced this issue Apr 3, 2017
…rs (k0pernikus, stof)

This PR was merged into the 2.7 branch.

Discussion
----------

[ExpressionLanguage] Provide the expression in syntax errors

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #19445
| License       | MIT
| Doc PR        | n/a

This finishes the PR #19449.

Commits
-------

7cd7441 Complete the injection of the expression in all syntax errors
dc55db2 add expression text to SyntaxError
@fabpot fabpot closed this as completed Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0