[Debug] Mimic __toString php behavior in FlattenException#28879
[Debug] Mimic __toString php behavior in FlattenException#28879fabpot merged 1 commit intosymfony:masterfrom
Conversation
13eb183 to
1fdaa39
Compare
|
Thanks for the PR. |
1fdaa39 to
701a540
Compare
|
@nicolas-grekas For the So i don't really see cases where this can leak sensitive data? |
3fa4f16 to
0323df8
Compare
|
Fine for getTraceAsString. Do you have a use case where this would help? |
|
|
|
@fabpot if this is not the goal then at least the return type declaration of It the behaivor wanted is that @nicolas-grekas The use case i have mentioned is to access the exception of a failed request in a |
|
Any news here? |
4cc7e46 to
ff2f7d2
Compare
ff2f7d2 to
514a1b5
Compare
|
@fabpot have changed the method name to what @nicolas-grekas suggested. Tests have run through. |
|
Thank you @Deltachaos. |
…ion (Deltachaos) This PR was merged into the 4.3-dev branch. Discussion ---------- [Debug] Mimic __toString php behavior in FlattenException | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | symfony/symfony-docs# The `Symfony\Component\Debug\Exception\FlattenException` object is returned by `Symfony\Component\HttpKernel\DataCollector\ExceptionDataCollector::getException` method, but the docblock of this method indicates that it should return `\Exception` object. As the `FlattenException` class should behave as much as possible like a php `\Exception` object, it should implement the same methods as `\Exception`. This PR is adding `__toString` and `getTraceAsString` methods. Those methods are (in my opinion) the most useful methods of a `\Exception` object. A potential use case (where i am stumbled across this inconsistency) is to get the last exception of a request in a `WebTestCase` using the profiler and printing the trace. Commits ------- 514a1b5 [Debug] Mimic __toString php behavior in FlattenException
The
Symfony\Component\Debug\Exception\FlattenExceptionobject is returned bySymfony\Component\HttpKernel\DataCollector\ExceptionDataCollector::getExceptionmethod, but the docblock of this method indicates that it should return\Exceptionobject.As the
FlattenExceptionclass should behave as much as possible like a php\Exceptionobject, it should implement the same methods as\Exception.This PR is adding
__toStringandgetTraceAsStringmethods. Those methods are (in my opinion) the most useful methods of a\Exceptionobject. A potential use case (where i am stumbled across this inconsistency) is to get the last exception of a request in aWebTestCaseusing the profiler and printing the trace.