Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[PropertyAccessor] remove try/catch or provide context into re-thrown exception #34899

Copy link
Copy link
Closed
@Pictor13

Description

@Pictor13
Issue body actions

I just had some debugging problem, when the PropertyAccessor is called from the Form component.

Specifically, the call to PropertyAccessor::writeProperty() is wrapped in a try/catch block and, in case of exception, it is re-thrown manually by the static method throwInvalidArgumentException().

Except for providing a namespaced custom exception, I am not sure why the try/catch is there, since I suppose that anybody would want the original error to be reported, when trying to set a property on target object/array.

In fact, re-throwing hinders the discovery of the actual problem, breaking the call-stack at the setValue () call instead of reporting what went wrong. Not really debuggable.
This is a screenshot from my specific case:

Screenshot 2019-12-09 at 19 10 40

"Expected argument of type "%s", "%s" given at property path "%s".

...after which I am left with guess work.
The re-thrown error message was too specific and not providing the context (File + Line where the real exception happened).

I am not sure about the benefits of re-throwing here.
So I am asking if it is possible to remove the try/catch.
Or eventually to change the re-throwing to at least report all the information provided from the original exception, rather than hiding them (atm the message doesn't help if we don't get the info of where this is happening).

What do you think about that?
Does it make sense?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXDX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)PropertyAccess

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.