Skip to content

[DependencyInjection] forward the parse error to the calling code #29928

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

Merged
merged 1 commit into from
Jan 20, 2019

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Jan 18, 2019

Q A
Branch? 3.4
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #29891
License MIT
Doc PR

This change does not fully solve the linked issue, but improves the exception a bit by providing a bit more context.

The error page will no start like this:

bildschirmfoto 2019-01-18 um 12 28 14

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you.

@przemyslaw-bogusz
Copy link
Contributor

We could implement an analogical change in XMLFileLoader, for users, who configure services using XML:

private function parseFileToDOM($file)
{
try {
$dom = XmlUtils::loadFile($file, [$this, 'validateSchema']);
} catch (\InvalidArgumentException $e) {
throw new InvalidArgumentException(sprintf('Unable to parse file "%s".', $file), $e->getCode(), $e);
}
$this->validateExtensions($dom, $file);
return $dom;
}

Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do the same for the XML loader?

@xabbuh
Copy link
Member Author

xabbuh commented Jan 20, 2019

done

@fabpot
Copy link
Member

fabpot commented Jan 20, 2019

Thank you @xabbuh.

@fabpot fabpot merged commit c5c2d31 into symfony:3.4 Jan 20, 2019
fabpot added a commit that referenced this pull request Jan 20, 2019
…ling code (xabbuh)

This PR was merged into the 3.4 branch.

Discussion
----------

[DependencyInjection] forward the parse error to the calling code

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29891
| License       | MIT
| Doc PR        |

This change does not fully solve the linked issue, but improves the exception a bit by providing a bit more context.

The error page will no start like this:

![bildschirmfoto 2019-01-18 um 12 28 14](https://user-images.githubusercontent.com/1957048/51384558-f7af3600-1b1c-11e9-9744-a40c41c821ce.png)

Commits
-------

c5c2d31 forward the parse error to the calling code
@xabbuh xabbuh deleted the issue-29891 branch January 20, 2019 08:29
fabpot added a commit that referenced this pull request Jan 20, 2019
This PR was merged into the 3.4 branch.

Discussion
----------

[DependencyInjection] fix tests

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29928
| License       | MIT
| Doc PR        |

My changes in #29928 broke the test suite.

Commits
-------

4db0a6e fix tests
nicolas-grekas added a commit that referenced this pull request Feb 7, 2019
…of Debug (javiereguiluz)

This PR was squashed before being merged into the 4.3-dev branch (closes #30024).

Discussion
----------

[Debug] Display more details in the simple error page of Debug

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29891
| License       | MIT
| Doc PR        | -

Note: this only changes the simple error page of Debug component, which is different from the full-featured error page of WebProfilerBundle.

-----

#29891 shows a confusing error page. In #29928 we improved the first error message displayed to the user. In this PR we implement @nicolas-grekas' idea to replace the generic error page title by a better error message. So, this PR + #29928 would fix #29891 to me.

### Before

![error-before](https://user-images.githubusercontent.com/73419/51920135-1519b500-23e5-11e9-99d6-e9b631b97499.png)

### After

![error-after](https://user-images.githubusercontent.com/73419/51920141-1945d280-23e5-11e9-97c3-49b2170dbd15.png)

Commits
-------

75ff151 [Debug] Display more details in the simple error page of Debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants