8000 [PropertyAccessor] Original exception not always passed to throwUnexpectedTypeException · Issue #38621 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[PropertyAccessor] Original exception not always passed to throwUnexpectedTypeException #38621

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
thelem opened this issue Oct 18, 2020 · 3 comments

Comments

@thelem
Copy link
thelem commented Oct 18, 2020

Description
#18210 introduced throwUnexpectedTypeException()
#34899 extended this to wrap the original exception, and passed the original exception while inside the setValue function

However, by the time this came to be merged into 4.3:
7f2d9c2
there were two calls to throwUnexpectedTypeException, and only one of them was given the original exception. It should be passed in both calls.

The benefit is as described by @Pictor13 on #34899

In my case I was passing null to a setter that was typed not to accept nulls, even though it was backed on to a nullable field. The error message I was shown made me look at my field definition, when in fact I needed to look at the setter.

Example

Screenshot of stacktrace after changing the call to pass the original exception

Screenshot_2020-10-18 Expected argument of type string , null given at property path buttonLabels (500 Internal Server Error)

@thelem thelem changed the title [PropertyAccessor] [PropertyAccessor] Original exception not always passed to throwUnexpectedTypeException Oct 18, 2020
@thelem
Copy link
Author
thelem commented Oct 18, 2020

Problem was reproduced in 4.4.13, but looking at the source code I can see it is still an issue in 5.1

@xabbuh
Copy link
Member
xabbuh commented Oct 20, 2020

see #38645

@fabpot fabpot closed this as completed Oct 20, 2020
fabpot added a commit that referenced this issue Oct 20, 2020
This PR was merged into the 4.4 branch.

Discussion
----------

[PropertyAccess] forward the caught exception

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #38621
| License       | MIT
| Doc PR        |

Commits
-------

143f82e forward the caught exception
@iant-ee
Copy link
iant-ee commented Oct 20, 2020

Great to see this turned around so quickly. Thanks @xabbuh, @derrabus, @jderusse and @fabian - a great first experience of the symfony issue queue.

6B04

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

6 participants
0